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-2020 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 #ifndef SWIG
163  void* custom_data = 0
164 #endif
165  );
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 
340  std::vector<Obj> ImportObjs(const std::vector<Obj>& obj_list, const std::vector<Obj>& exclude_list);
341 
345  UInt32 XRefSize () const;
346 
350  void ClearMarks ();
351 
353  {
354  e_incremental = 0x01, // Save the document using incremental mode.
355  e_remove_unused = 0x02, // Remove unused objects. Requires full save.
356  e_hex_strings = 0x04, // Save all string in hexadecimal format.
357  e_omit_xref = 0x08, // Do not save cross-reference table
358  e_linearized = 0x10, // Save the document in linearized (fast web-view) format. Requires full save.
359  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).
360  };
361 
362 #ifndef SWIG
363 
388  void Save(const UString& path, UInt32 flags, Common::ProgressMonitor* progress, const char* header);
389 #endif
390 
415  void Save(const UString& path, UInt32 flags, const char* header);
416 
431  std::vector<unsigned char> Save(UInt32 flags, const char* header);
432 
433 #ifndef SWIG
434 
452  void Save(const char* &out_buf, size_t& out_buf_size, UInt32 flags, Common::ProgressMonitor* progress, const char* header);
453 #endif
454 
468  void Save(Filters::Filter stream, UInt32 flags, const char* header);
469 
478  const char* GetHeader() const;
479 
495 
507  void SetSecurityHandler (SecurityHandler handler);
508 
512  void RemoveSecurity();
513 
530  void Swap(UInt32 obj_num1, UInt32 obj_num2);
531 
541  Obj CreateIndirectName(const char* name);
560  Obj CreateIndirectBool(bool value);
563  Obj CreateIndirectNumber(double value);
564  Obj CreateIndirectString(const UChar* value, UInt32 size);
565  Obj CreateIndirectString(const UString& str);
566 
571  Obj CreateIndirectStream(const char* data, const size_t data_size, Filters::Filter filter_chain =Filters::Filter());
572 
573 
593  bool IsLinearized() const;
594 
602 
609  SDF::Obj GetHintStream() const;
610 
616  void Lock();
617 
621  void Unlock();
622 
628  bool TryLock( int milliseconds = 0 );
629 
640  void LockRead();
641 
645  void UnlockRead();
646 
652  bool TryLockRead( int milliseconds = 0 );
653 
659  UString GetFileName() const;
660 
667  void EnableDiskCaching( bool use_cache_flag );
668 
669 
670  //for xamarin use only
671  static SDFDoc* CreateInternal(ptrdiff_t impl);
672  ptrdiff_t GetHandleInternal();
673 
674  // @cond PRIVATE_DOC
675  #ifndef SWIGHIDDEN
676  SDFDoc(TRN_SDFDoc doc) : mp_doc(doc) {}
677  TRN_SDFDoc mp_doc;
678 private:
679  SDFDoc(SDFDoc& other);
680  SDFDoc& operator=(SDFDoc& other);
681  #endif
682  // @endcond
683 };
684 
685 
686  }; // namespace SDF
687 }; // namespace pdftron
688 
689 
690 #include <Impl/SDFDoc.inl>
691 
692 #endif // PDFTRON_H_CPPSDFSDFDoc
Obj CreateIndirectString(const UChar *value, UInt32 size)
bool InitStdSecurityHandler(const char *password, int password_sz)
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
bool InitSecurityHandler(void *custom_data=0)
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 Save(const UString &path, UInt32 flags, Common::ProgressMonitor *progress, const char *header)
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)