All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SDFDoc.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------------------
2 // Copyright (c) 2001-2018 by PDFTron Systems Inc. All Rights Reserved.
3 // Consult legal.txt regarding legal and license information.
4 //---------------------------------------------------------------------------------------
5 #ifndef PDFTRON_H_CPPSDFSDFDoc
6 #define PDFTRON_H_CPPSDFSDFDoc
7 
8 #include <Common/Matrix2D.h>
9 #include <Filters/FilterReader.h>
10 #include <vector>
11 
12 namespace pdftron {
13  namespace Common {
14  struct ProgressMonitor;
15  }
16 
17  namespace SDF {
18 
19 
20 // forward declarations
21 class Obj;
22 class SecurityHandler;
23 
67 class SDFDoc
68 {
69 public:
70 
77  SDFDoc ();
78 
87  SDFDoc (const UString& filepath);
88  SDFDoc (const char* filepath);
89 
104  SDFDoc (Filters::Filter stream);
105 
119  SDFDoc (unsigned char* buf, size_t buf_size);
120 
124  ~SDFDoc ();
125 
129  void Close();
130 
134  bool IsEncrypted();
135 
161  bool InitSecurityHandler ();
162 
163 #ifndef SWIG
164  bool InitSecurityHandler (void* custom_data);
165 #endif
166 
199  bool InitStdSecurityHandler (const char* password, int password_sz);
200 
227  bool InitStdSecurityHandler(const pdftron::UString& password);
228 
255  bool InitStdSecurityHandler(const std::vector<UInt8>& password_buf);
256 
260  bool IsModified () const;
261 
273  bool HasRepairedXRef() const;
274 
278  bool IsFullSaveRequired () const;
279 
284  Obj GetTrailer ();
285 
291  Obj GetObj (const UInt32 obj_num) const;
292 
307  Obj ImportObj (Obj obj, bool deep_copy);
308 
323  std::vector<Obj> ImportObjs(const std::vector<Obj>& obj_list);
324 
328  UInt32 XRefSize () const;
329 
333  void ClearMarks ();
334 
336  {
337  e_incremental = 0x01, // Save the document using incremental mode.
338  e_remove_unused = 0x02, // Remove unused objects. Requires full save.
339  e_hex_strings = 0x04, // Save all string in hexadecimal format.
340  e_omit_xref = 0x08, // Do not save cross-reference table
341  e_linearized = 0x10, // Save the document in linearized (fast web-view) format. Requires full save.
342  e_compatibility = 0x20 // Save the document in a manner that maximizes compatibility with older PDF consumers (e.g. the file will not use compressed object and xref streams).
343  };
344 
370  void Save(const UString& path, UInt32 flags, const char* header);
371 
372 #ifndef SWIG
373  void Save(const UString& path, UInt32 flags, Common::ProgressMonitor* progress, const char* header);
374 #endif
375 
394  std::vector<unsigned char> Save(UInt32 flags, const char* header);
395 
396 #ifndef SWIG
397  void Save(const char* &out_buf, size_t& out_buf_size, UInt32 flags, Common::ProgressMonitor* progress, const char* header);
398 #endif
399 
413  void Save(Filters::Filter stream, UInt32 flags, const char* header);
414 
423  const char* GetHeader() const;
424 
440 
452  void SetSecurityHandler (SecurityHandler handler);
453 
457  void RemoveSecurity();
458 
475  void Swap(UInt32 obj_num1, UInt32 obj_num2);
476 
486  Obj CreateIndirectName(const char* name);
505  Obj CreateIndirectBool(bool value);
508  Obj CreateIndirectNumber(double value);
509  Obj CreateIndirectString(const UChar* value, UInt32 size);
510  Obj CreateIndirectString(const UString& str);
511 
516  Obj CreateIndirectStream(const char* data, const size_t data_size, Filters::Filter filter_chain =Filters::Filter());
517 
518 
538  bool IsLinearized() const;
539 
547 
554  SDF::Obj GetHintStream() const;
555 
561  void Lock();
562 
566  void Unlock();
567 
573  bool TryLock( int milliseconds = 0 );
574 
585  void LockRead();
586 
590  void UnlockRead();
591 
597  bool TryLockRead( int milliseconds = 0 );
598 
604  UString GetFileName() const;
605 
612  void EnableDiskCaching( bool use_cache_flag );
613 
614 
615  //for xamarin use only
616  static SDFDoc* CreateInternal(ptrdiff_t impl);
617  ptrdiff_t GetHandleInternal();
618 
620  #ifndef SWIGHIDDEN
621  SDFDoc(TRN_SDFDoc doc) : mp_doc(doc) {}
622  TRN_SDFDoc mp_doc;
623 private:
624  SDFDoc(SDFDoc& other);
625  SDFDoc& operator=(SDFDoc& other);
626  #endif
627 };
629 
630 
631  }; // namespace SDF
632 }; // namespace pdftron
633 
634 
635 #include <Impl/SDFDoc.inl>
636 
637 #endif // PDFTRON_H_CPPSDFSDFDoc
Obj CreateIndirectString(const UChar *value, UInt32 size)
bool InitStdSecurityHandler(const char *password, int password_sz)
void Save(const UString &path, UInt32 flags, const char *header)
SDF::Obj GetHintStream() const
SecurityHandler GetSecurityHandler()
Obj CreateIndirectBool(bool value)
bool HasRepairedXRef() const
Obj CreateIndirectStream(Filters::FilterReader &data, Filters::Filter filter_chain=Filters::Filter())
void EnableDiskCaching(bool use_cache_flag)
Obj GetObj(const UInt32 obj_num) const
Obj CreateIndirectName(const char *name)
bool TryLockRead(int milliseconds=0)
bool IsFullSaveRequired() const
UInt32 XRefSize() const
static SDFDoc * CreateInternal(ptrdiff_t impl)
const char * GetHeader() const
TRN_UInt32 UInt32
Definition: BasicTypes.h:13
ptrdiff_t GetHandleInternal()
UString GetFileName() const
bool IsLinearized() const
SDF::Obj GetLinearizationDict() const
TRN_UChar UChar
Definition: BasicTypes.h:12
bool TryLock(int milliseconds=0)
void SetSecurityHandler(SecurityHandler handler)
Obj CreateIndirectNumber(double value)
void Swap(UInt32 obj_num1, UInt32 obj_num2)
Obj ImportObj(Obj obj, bool deep_copy)
bool IsModified() const
std::vector< Obj > ImportObjs(const std::vector< Obj > &obj_list)

© 2002-2014 PDFTron Systems Inc.