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-2024 by Apryse Software 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 
451  void Save(const char* &out_buf, size_t& out_buf_size, UInt32 flags, Common::ProgressMonitor* progress, const char* header);
452 #endif
453 
466  void Save(Filters::Filter stream, UInt32 flags, const char* header);
467 
476  const char* GetHeader() const;
477 
493 
505  void SetSecurityHandler (SecurityHandler handler);
506 
510  void RemoveSecurity();
511 
528  void Swap(UInt32 obj_num1, UInt32 obj_num2);
529 
539  Obj CreateIndirectName(const char* name);
558  Obj CreateIndirectBool(bool value);
561  Obj CreateIndirectNumber(double value);
562  Obj CreateIndirectString(const UChar* value, UInt32 size);
563  Obj CreateIndirectString(const UString& str);
564 
569  Obj CreateIndirectStream(const char* data, const size_t data_size, Filters::Filter filter_chain =Filters::Filter());
570 
571 
591  bool IsLinearized() const;
592 
600 
607  SDF::Obj GetHintStream() const;
608 
614  void Lock();
615 
619  void Unlock();
620 
626  bool TryLock( int milliseconds = 0 );
627 
638  void LockRead();
639 
643  void UnlockRead();
644 
650  bool TryLockRead( int milliseconds = 0 );
651 
657  UString GetFileName() const;
658 
665  void EnableDiskCaching( bool use_cache_flag );
666 
667 
668  //for xamarin use only
669  static SDFDoc* CreateInternal(ptrdiff_t impl);
670  ptrdiff_t GetHandleInternal();
671 
672  // @cond PRIVATE_DOC
673  #ifndef SWIGHIDDEN
674  SDFDoc(TRN_SDFDoc doc) : mp_doc(doc) {}
675  TRN_SDFDoc mp_doc;
676 private:
677  SDFDoc(SDFDoc& other);
678  SDFDoc& operator=(SDFDoc& other);
679  #endif
680  // @endcond
681 };
682 
683 
684  }; // namespace SDF
685 }; // namespace pdftron
686 
687 
688 #include <Impl/SDFDoc.inl>
689 
690 #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)