- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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-2025 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
352 enum SaveOptions
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
492 SecurityHandler GetSecurityHandler ();
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);
548 Obj CreateIndirectArray();
558 Obj CreateIndirectBool(bool value);
559 Obj CreateIndirectDict();
560 Obj CreateIndirectNull();
561 Obj CreateIndirectNumber(double value);
562 Obj CreateIndirectString(const UChar* value, UInt32 size);
563 Obj CreateIndirectString(const UString& str);
564
568 Obj CreateIndirectStream(Filters::FilterReader& data, Filters::Filter filter_chain=Filters::Filter());
569 Obj CreateIndirectStream(const char* data, const size_t data_size, Filters::Filter filter_chain =Filters::Filter());
570
571
591 bool IsLinearized() const;
592
599 SDF::Obj GetLinearizationDict() const;
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
pdftron::SDF::SDFDoc::CreateIndirectString
Obj CreateIndirectString(const UChar *value, UInt32 size)
pdftron::SDF::SDFDoc::LockRead
void LockRead()
pdftron::SDF::SDFDoc::InitStdSecurityHandler
bool InitStdSecurityHandler(const char *password, int password_sz)
FilterReader.h
pdftron::SDF::SDFDoc::CreateIndirectDict
Obj CreateIndirectDict()
pdftron::SDF::SDFDoc::e_remove_unused
Definition: SDFDoc.h:355
pdftron::SDF::SDFDoc::GetHintStream
SDF::Obj GetHintStream() const
pdftron::SDF::SDFDoc::GetSecurityHandler
SecurityHandler GetSecurityHandler()
pdftron::SDF::SDFDoc::CreateIndirectBool
Obj CreateIndirectBool(bool value)
pdftron::SDF::SDFDoc::GetTrailer
Obj GetTrailer()
pdftron::SDF::SDFDoc::HasRepairedXRef
bool HasRepairedXRef() const
pdftron::SDF::SDFDoc::CreateIndirectStream
Obj CreateIndirectStream(Filters::FilterReader &data, Filters::Filter filter_chain=Filters::Filter())
pdftron::SDF::SDFDoc::EnableDiskCaching
void EnableDiskCaching(bool use_cache_flag)
pdftron::SDF::SDFDoc::GetObj
Obj GetObj(const UInt32 obj_num) const
pdftron::SDF::SDFDoc::CreateIndirectName
Obj CreateIndirectName(const char *name)
pdftron::SDF::SDFDoc::SDFDoc
SDFDoc()
Matrix2D.h
pdftron::SDF::SDFDoc::TryLockRead
bool TryLockRead(int milliseconds=0)
pdftron::SDF::SDFDoc::IsFullSaveRequired
bool IsFullSaveRequired() const
pdftron::SDF::SDFDoc::InitSecurityHandler
bool InitSecurityHandler(void *custom_data=0)
pdftron::SDF::SDFDoc::XRefSize
UInt32 XRefSize() const
pdftron::SDF::SDFDoc::CreateInternal
static SDFDoc * CreateInternal(ptrdiff_t impl)
pdftron::SDF::SDFDoc::GetHeader
const char * GetHeader() const
pdftron::UInt32
TRN_UInt32 UInt32
Definition: BasicTypes.h:13
pdftron::SDF::SDFDoc::GetHandleInternal
ptrdiff_t GetHandleInternal()
pdftron::SDF::SDFDoc::GetFileName
UString GetFileName() const
pdftron::SDF::SDFDoc::e_incremental
Definition: SDFDoc.h:354
pdftron::SDF::SDFDoc::IsLinearized
bool IsLinearized() const
pdftron::SDF::SDFDoc::GetLinearizationDict
SDF::Obj GetLinearizationDict() const
pdftron::SDF::SDFDoc::UnlockRead
void UnlockRead()
pdftron::SDF::SDFDoc::e_omit_xref
Definition: SDFDoc.h:357
pdftron::SDF::SDFDoc::SaveOptions
SaveOptions
Definition: SDFDoc.h:352
pdftron::SDF::SDFDoc
Definition: SDFDoc.h:67
pdftron::SDF::SDFDoc::e_linearized
Definition: SDFDoc.h:358
pdftron::SDF::SDFDoc::Unlock
void Unlock()
pdftron::UChar
TRN_UChar UChar
Definition: BasicTypes.h:12
pdftron::SDF::SDFDoc::TryLock
bool TryLock(int milliseconds=0)
pdftron::Filters::Filter
Definition: Filter.h:45
pdftron::SDF::SDFDoc::Close
void Close()
pdftron::SDF::SDFDoc::SetSecurityHandler
void SetSecurityHandler(SecurityHandler handler)
pdftron::SDF::SDFDoc::CreateIndirectNumber
Obj CreateIndirectNumber(double value)
pdftron::SDF::SDFDoc::e_hex_strings
Definition: SDFDoc.h:356
pdftron::SDF::SDFDoc::ClearMarks
void ClearMarks()
pdftron::SDF::SDFDoc::Lock
void Lock()
pdftron::SDF::SDFDoc::Save
void Save(const UString &path, UInt32 flags, Common::ProgressMonitor *progress, const char *header)
pdftron::SDF::SDFDoc::RemoveSecurity
void RemoveSecurity()
pdftron::SDF::SDFDoc::CreateIndirectArray
Obj CreateIndirectArray()
pdftron::Filters::FilterReader
Definition: FilterReader.h:29
pdftron::SDF::SDFDoc::Swap
void Swap(UInt32 obj_num1, UInt32 obj_num2)
pdftron::SDF::SecurityHandler
Definition: SecurityHandler.h:22
pdftron::SDF::SDFDoc::IsEncrypted
bool IsEncrypted()
pdftron::SDF::Obj
Definition: Obj.h:40
pdftron::SDF::SDFDoc::CreateIndirectNull
Obj CreateIndirectNull()
pdftron::SDF::SDFDoc::ImportObj
Obj ImportObj(Obj obj, bool deep_copy)
pdftron::UString
Definition: UString.h:27
pdftron::SDF::SDFDoc::IsModified
bool IsModified() const
pdftron::SDF::SDFDoc::e_compatibility
Definition: SDFDoc.h:359
pdftron::SDF::SDFDoc::ImportObjs
std::vector< Obj > ImportObjs(const std::vector< Obj > &obj_list)
pdftron::SDF::SDFDoc::~SDFDoc
~SDFDoc()