Foxit PDF SDK

fs_pdfobject.h
Go to the documentation of this file.
1
15 #ifndef FS_PDFOBJECT_H_
16 #define FS_PDFOBJECT_H_
17
18 #include "common/fs_common.h"
19 #include "common/file/fs_file.h"
20
26 namespace foxit {
30 namespace pdf {
34 namespace objects {
35 class PDFArray;
36 class PDFDictionary;
37 class PDFStream;
38
55 class PDFObject : public Object {
56 public:
62 typedef enum _Type {
64 e_InvalidType = 0,
66 e_Boolean = 1,
68 e_Number = 2,
70 e_String = 3,
72 e_Name = 4,
74 e_Array = 5,
76 e_Dictionary = 6,
78 e_Stream = 7,
80 e_Null = 8,
82 e_Reference = 9
83 } Type;
84
85
97 static PDFObject* CreateFromBoolean(bool boolean_value);
98
110 static PDFObject* CreateFromFloat(float float_value);
111
123 static PDFObject* CreateFromInteger(int integer_value);
124
136 static PDFObject* CreateFromString(const wchar_t* string_value);
137
151 static PDFObject* CreateFromString(const wchar_t* string_value, int length);
152
162 static PDFObject* CreateFromNameW(const wchar_t* name);
163
175 static PDFObject* CreateFromName(const char* name);
176
192 static PDFObject* CreateFromDateTime(const DateTime& date_time);
193
212 static PDFObject* CreateReference(PDFDoc document, uint32 object_number);
213
225 void Release();
226
236 PDFObject* CloneObject() const;
237
249 PDFObject* DeepCloneObject() const;
250
259 bool IsIdentical(PDFObject* pdf_obj) const;
260
267 Type GetType() const;
268
279 uint32 GetObjNum() const;
280
288 int GetInteger() const;
289
297 float GetFloat() const;
298
306 bool GetBoolean() const;
307
317 Matrix GetMatrix() const;
318
328 RectF GetRect() const;
329
339 PDFObject* GetDirectObject() const;
340
350 DateTime GetDateTime() const;
351
361 String GetName() const;
362
379 String GetString() const;
380
397 WString GetWideString() const;
398
408 PDFArray* GetArray();
409
419 PDFDictionary* GetDict();
420
430 PDFStream* GetStream();
431
432 protected:
433 ~PDFObject() {}
434
435 private:
436 PDFObject(const PDFObject&);
437 PDFObject &operator = (const PDFObject& object);
438 };
439
448 class PDFStream FS_FINAL : public PDFObject {
449 public:
457 typedef enum _Filter {
459 e_Unknown = -1,
461 e_NoneDecode = 0,
466 e_ASCIIHexDecode = 1,
471 e_ASCII85Decode = 2,
476 e_LZWDecode = 3,
481 e_FlateDecode = 4,
488 e_RunLengthDecode = 5,
493 e_CCITTFaxDecode = 6,
498 e_JBIG2Decode = 7,
503 e_DCTDecode = 8,
508 e_JPXDecode = 9,
513 e_Crypt = 10
514 } Filter;
515
532 static PDFStream* Create(PDFDictionary* dictionary);
533
540 PDFDictionary* GetDictionary();
541
548 Filter GetStreamFilter();
549
559 uint64 GetDataSize(bool is_raw_data);
560
579 bool GetData(bool is_raw_data, size_t size, void* out_buffer);
580
589 void SetData(const void* buffer, size_t size);
590
605 void ImportData(common::file::ReaderCallback* file_read, Filter stream_filter);
606
623 common::file::ReaderCallback* ExportData(bool is_raw_data);
624
625 private:
626 PDFStream(const PDFStream&);
627 PDFStream &operator = (const PDFStream& stream);
628 };
629
640 class PDFArray FS_FINAL : public PDFObject {
641 public:
651 static PDFArray* Create();
652
664 static PDFArray* CreateFromMatrix(const Matrix& matrix);
665
677 static PDFArray* CreateFromRect(const RectF& rect);
678
684 int GetElementCount() const;
685
695 PDFObject* GetElement(int index) const;
696
704 void AddElement(PDFObject* element);
705
713 void AddBoolean(bool boolean_value);
714
722 void AddDateTime(const DateTime& date_time);
723
731 void AddFloat(float float_value);
732
740 void AddInteger(int integer_value);
741
749 void AddMatrix(const Matrix& matrix);
750
758 void AddRect(const RectF& rect);
759
768 void AddName(const char* name);
769
778 void AddString(const wchar_t* new_string);
779
794 void InsertAt(int index, PDFObject* element);
795
806 void SetAt(int index, PDFObject* element);
807
817 void RemoveAt(int index);
818
832 void AddReference(PDFObject* pdf_object, PDFDoc document);
833
834 private:
835 PDFArray(const PDFArray&);
836 PDFArray &operator = (const PDFArray& array_object);
837 };
838
850 class PDFDictionary FS_FINAL : public PDFObject {
851 public:
861 static PDFDictionary* Create();
862
870 bool HasKey(const char* key) const;
871
880 PDFObject* GetElement(const char* key) const;
881
891 POSITION MoveNext(POSITION position);
892
900 String GetKey(POSITION position) const;
901
910 PDFObject* GetValue(POSITION position) const;
911
924 void SetAt(const char* key, PDFObject* pdf_object);
925
940 void SetAtReference(const char* key, PDFObject* pdf_object, PDFDoc document);
941
950 void SetAtBoolean(const char* key, bool value);
951
960 void SetAtDateTime(const char* key, const DateTime& value);
961
970 void SetAtFloat(const char* key, float value);
971
980 void SetAtInteger(const char* key, int value);
981
990 void SetAtMatrix(const char* key, const Matrix& value);
991
1000 void SetAtRect(const char* key, const RectF& value);
1001
1010 void SetAtName(const char* key, const char* value);
1011
1022 void SetAtString(const char* key, const char* value);
1023
1034 void SetAtString(const char* key, const wchar_t* value);
1035
1043 void RemoveAt(const char* key);
1044
1045 private:
1046 PDFDictionary(const PDFDictionary&);
1047 PDFDictionary &operator = (const PDFDictionary& dictionary);
1048 };
1049
1051 typedef CFX_ArrayTemplate<PDFDictionary*> PDFDictionaryArray;
1052
1053 } // namespace objects
1054 } // namespace pdf
1055 } // namespace foxit
1056 #endif // FS_PDFOBJECT_H_
1057
foxit::pdf::objects::PDFDictionary::MoveNext
POSITION MoveNext(POSITION position)
Move to the position of first or the next entry.
foxit::pdf::objects::PDFObject::e_Boolean
PDF boolean object.
Definition: fs_pdfobject.h:66
foxit::pdf::objects::PDFObject::e_Array
PDF array object.
Definition: fs_pdfobject.h:74
foxit::pdf::objects::PDFObject::IsIdentical
bool IsIdentical(PDFObject *pdf_obj) const
Check if input PDF object is identical with current PDF object.
foxit::pdf::objects::PDFObject::e_Null
PDF null object.
Definition: fs_pdfobject.h:80
foxit::pdf::objects::PDFObject::e_String
PDF string object.
Definition: fs_pdfobject.h:70
foxit::pdf::objects::PDFArray
Definition: fs_pdfobject.h:640
foxit::pdf::objects::PDFStream::GetStreamFilter
Filter GetStreamFilter()
Get the type of stream filter which indicate how the stream data must be decoded before the data is u...
foxit::pdf::objects::PDFArray::AddInteger
void AddInteger(int integer_value)
Add an integer value to the end of current PDF array object.
foxit::pdf::objects::PDFDictionary::SetAtMatrix
void SetAtMatrix(const char *key, const Matrix &value)
Set a matrix object as value element to an entry specified by key.
foxit::pdf::objects::PDFStream::e_ASCIIHexDecode
Filter type: ASCIIHexDecode, which means to decode data encoded in an ASCII hexadecimal representatio...
Definition: fs_pdfobject.h:466
foxit::pdf::objects::PDFDictionary::Create
static PDFDictionary * Create()
Create a new dictionary object.
foxit::DateTime
Definition: fs_basictypes.h:484
foxit::pdf::objects::PDFArray::AddElement
void AddElement(PDFObject *element)
Add a PDF object to the end of current PDF array object.
foxit::pdf::objects::PDFStream::e_ASCII85Decode
Filter type: ASCII85Decode, which means to decode data encoded in an ASCII base-85 representation,...
Definition: fs_pdfobject.h:471
foxit::pdf::objects::PDFArray::AddReference
void AddReference(PDFObject *pdf_object, PDFDoc document)
Set the reference object of an indirect PDF object (whose object number is always above 0) as value e...
foxit::pdf::objects::PDFObject::CreateFromFloat
static PDFObject * CreateFromFloat(float float_value)
Create a PDF object from a float number.
foxit::Object
CFX_Object Object
Object type.
Definition: fs_basictypes.h:220
foxit::pdf::objects::PDFObject::e_InvalidType
Invalid PDF object type.
Definition: fs_pdfobject.h:64
foxit::POSITION
FX_POSITION POSITION
A value used to denote the position of an element in a collection.
Definition: fs_basictypes.h:205
foxit::pdf::objects::PDFArray::CreateFromRect
static PDFArray * CreateFromRect(const RectF &rect)
Create a new array object for a rectangle.
foxit::pdf::objects::PDFObject::GetDirectObject
PDFObject * GetDirectObject() const
Get the direct object of current PDF object.
foxit::pdf::objects::PDFDictionary::SetAtName
void SetAtName(const char *key, const char *value)
Set a string (as PDF name object) as value element to an entry specified by key.
fs_common.h
Header file for common definitions and classes.
foxit::pdf::objects::PDFObject::GetRect
RectF GetRect() const
Get the rectangle value of current PDF object.
foxit::pdf::objects::PDFStream::Filter
Filter
Enumeration for stream filter type.
Definition: fs_pdfobject.h:457
foxit::pdf::objects::PDFObject::Type
Type
Enumeration for PDF object type.
Definition: fs_pdfobject.h:62
foxit::pdf::objects::PDFObject::e_Number
PDF number object.
Definition: fs_pdfobject.h:68
foxit::pdf::objects::PDFArray::AddFloat
void AddFloat(float float_value)
Add a float value to the end of current PDF array object.
foxit::pdf::objects::PDFDictionary::SetAtReference
void SetAtReference(const char *key, PDFObject *pdf_object, PDFDoc document)
Set the reference object of an indirect PDF object (whose object number is always above 0) as value e...
CFX_ArrayTemplate
Definition: fx_basic.h:1297
foxit::pdf::objects::PDFDictionary::GetKey
String GetKey(POSITION position) const
Get the key of an entry specified by position.
IFX_FileRead
File reading interface.
Definition: fx_stream.h:587
foxit::pdf::objects::PDFDictionary::HasKey
bool HasKey(const char *key) const
Check whether there is an entry with specified key in current dictionary or not.
fs_file.h
Header file for file operation related definitions and functions.
foxit::pdf::objects::PDFDictionary::GetElement
PDFObject * GetElement(const char *key) const
Get the value element of an entry with specified key.
foxit::pdf::objects::PDFArray::AddName
void AddName(const char *name)
Add a string as PDF name object to the end of current PDF array object.
foxit::pdf::objects::PDFArray::AddDateTime
void AddDateTime(const DateTime &date_time)
Add a date time to the end of current PDF array object.
foxit::pdf::objects::PDFDictionaryArray
CFX_ArrayTemplate< PDFDictionary * > PDFDictionaryArray
Definition: fs_pdfobject.h:1051
foxit::pdf::objects::PDFStream::e_DCTDecode
Filter type: DCTDecode, which means to decompress data encoded using a DCT (discrete cosine transform...
Definition: fs_pdfobject.h:503
foxit::pdf::objects::PDFObject
Definition: fs_pdfobject.h:55
foxit::pdf::objects::PDFObject::CreateFromNameW
static PDFObject * CreateFromNameW(const wchar_t *name)
Create a PDF object from a string which represents a name.
foxit::pdf::objects::PDFObject::CreateFromDateTime
static PDFObject * CreateFromDateTime(const DateTime &date_time)
Create a PDF object from date time.
foxit::pdf::objects::PDFDictionary::SetAtRect
void SetAtRect(const char *key, const RectF &value)
Set a rectangle object as value element to an entry specified by key.
foxit::pdf::objects::PDFStream::e_LZWDecode
Filter type: LZWDecode, which means to decompress data encoded using the LZW (Lempel-Ziv-Welch) adapt...
Definition: fs_pdfobject.h:476
foxit::pdf::objects::PDFDictionary::GetValue
PDFObject * GetValue(POSITION position) const
Get the value element of an entry specified by position.
foxit::pdf::objects::PDFStream::GetDataSize
uint64 GetDataSize(bool is_raw_data)
Get the size of stream data, in bytes.
foxit::pdf::objects::PDFObject::GetDict
PDFDictionary * GetDict()
Get the PDF dictionary object of current PDF object.
foxit::pdf::objects::PDFStream::SetData
void SetData(const void *buffer, size_t size)
Set stream data.
foxit::pdf::objects::PDFArray::AddBoolean
void AddBoolean(bool boolean_value)
Add a boolean value to the end of current PDF array object.
foxit::pdf::objects::PDFStream::Create
static PDFStream * Create(PDFDictionary *dictionary)
Create a new stream object based on a dictionary.
foxit::pdf::objects::PDFArray::Create
static PDFArray * Create()
Create a new array object.
foxit::pdf::objects::PDFObject::GetBoolean
bool GetBoolean() const
Get the boolean value of current PDF object.
foxit::pdf::objects::PDFObject::CreateReference
static PDFObject * CreateReference(PDFDoc document, uint32 object_number)
Create a reference for an indirect object.
CFX_ByteString
BYTE STRING CLASS.
Definition: fx_string.h:317
foxit::pdf::objects::PDFDictionary::SetAtString
void SetAtString(const char *key, const char *value)
Set a string as value element to an entry specified by key.
foxit::pdf::objects::PDFObject::e_Dictionary
PDF dictionary object.
Definition: fs_pdfobject.h:76
foxit::pdf::objects::PDFDictionary::SetAtBoolean
void SetAtBoolean(const char *key, bool value)
Set boolean element an entry specified by key.
foxit::pdf::objects::PDFArray::RemoveAt
void RemoveAt(int index)
Remove an element in a specified position (by index) from current PDF array object.
foxit::pdf::objects::PDFObject::GetDateTime
DateTime GetDateTime() const
Get the date time value of current PDF object.
foxit::pdf::objects::PDFObject::e_Reference
PDF reference object.
Definition: fs_pdfobject.h:82
foxit::pdf::objects::PDFStream::e_FlateDecode
Filter type: FlateDecode, which means to decompress data encoded using the zlib/deflate compression m...
Definition: fs_pdfobject.h:481
foxit::pdf::objects::PDFObject::CloneObject
PDFObject * CloneObject() const
Clone current PDF object and get the cloned PDF object.
foxit::pdf::objects::PDFStream::ExportData
common::file::ReaderCallback * ExportData(bool is_raw_data)
Export stream data.
foxit::pdf::objects::PDFObject::Release
void Release()
Release a newly created PDF object or a clone PDF object, which is not related to PDF document or oth...
foxit::pdf::objects::PDFObject::GetName
String GetName() const
Get the name value of current PDF object.
foxit::pdf::objects::PDFArray::AddRect
void AddRect(const RectF &rect)
Add a rectangle to the end of current PDF array object.
foxit
Foxit namespace.
Definition: fs_taggedpdf.h:27
foxit::pdf::objects::PDFObject::CreateFromInteger
static PDFObject * CreateFromInteger(int integer_value)
Create a PDF object from a integer number.
foxit::pdf::objects::PDFObject::GetWideString
WString GetWideString() const
Get the wide string value of current PDF object.
foxit::pdf::objects::PDFObject::GetString
String GetString() const
Get the string value of current PDF object.
foxit::pdf::objects::PDFStream::e_JPXDecode
Filter type: JPXDecode, which means to decompress data encoded using the wavelet-based JPEG2000 stand...
Definition: fs_pdfobject.h:508
foxit::pdf::objects::PDFDictionary
Definition: fs_pdfobject.h:850
foxit::pdf::objects::PDFStream::GetDictionary
PDFDictionary * GetDictionary()
Get the PDF dictionary object associated to current PDF stream object.
foxit::pdf::objects::PDFObject::CreateFromBoolean
static PDFObject * CreateFromBoolean(bool boolean_value)
Create a PDF object from a boolean value.
foxit::pdf::objects::PDFDictionary::SetAtFloat
void SetAtFloat(const char *key, float value)
Set a float element to an entry specified by key.
foxit::pdf::objects::PDFObject::GetArray
PDFArray * GetArray()
Get the PDF array object of current PDF object.
foxit::pdf::objects::PDFObject::GetInteger
int GetInteger() const
Get the integer value of current PDF object.
foxit::pdf::objects::PDFArray::GetElementCount
int GetElementCount() const
Get the count of elements.
foxit::pdf::objects::PDFObject::CreateFromName
static PDFObject * CreateFromName(const char *name)
Create a PDF object from a string which represents a name.
foxit::pdf::objects::PDFStream::e_JBIG2Decode
Filter type: JBIG2Decode, which means to decompress data encoded using the JBIG2 standard,...
Definition: fs_pdfobject.h:498
foxit::pdf::objects::PDFStream::e_Unknown
Unknown filter type.
Definition: fs_pdfobject.h:459
foxit::pdf::objects::PDFArray::AddString
void AddString(const wchar_t *new_string)
Add a string as PDF string object to the end of current PDF array object.
foxit::pdf::objects::PDFObject::e_Name
PDF name object.
Definition: fs_pdfobject.h:72
foxit::pdf::objects::PDFArray::GetElement
PDFObject * GetElement(int index) const
Get a specified element by index.
foxit::pdf::objects::PDFObject::GetMatrix
Matrix GetMatrix() const
Get the matrix value of current PDF object.
CFX_FloatRect
Definition: fx_coordinates.h:771
foxit::pdf::objects::PDFObject::GetStream
PDFStream * GetStream()
Get the PDF stream object of current PDF object.
foxit::pdf::objects::PDFStream::e_NoneDecode
No need to decode the stream data.
Definition: fs_pdfobject.h:461
foxit::pdf::objects::PDFStream::e_CCITTFaxDecode
Filter type: CCITTFaxDecode, which means to decompress data encoded using the CCITT facsimile standar...
Definition: fs_pdfobject.h:493
foxit::pdf::objects::PDFStream::GetData
bool GetData(bool is_raw_data, size_t size, void *out_buffer)
Get stream data.
foxit::pdf::PDFDoc
Definition: fs_pdfdoc.h:776
foxit::pdf::objects::PDFObject::CreateFromString
static PDFObject * CreateFromString(const wchar_t *string_value)
Create a PDF object from string.
foxit::pdf::objects::PDFStream::ImportData
void ImportData(common::file::ReaderCallback *file_read, Filter stream_filter)
Import stream data.
foxit::pdf::objects::PDFArray::SetAt
void SetAt(int index, PDFObject *element)
Set a new PDF object at a specified position in current PDF array object.
foxit::pdf::objects::PDFObject::DeepCloneObject
PDFObject * DeepCloneObject() const
Clone current PDF object and get the cloned PDF object.
foxit::pdf::objects::PDFArray::InsertAt
void InsertAt(int index, PDFObject *element)
Insert a PDF object to a specified position in current PDF array object.
foxit::pdf::objects::PDFObject::e_Stream
PDF stream object.
Definition: fs_pdfobject.h:78
CFX_Matrix
Definition: fx_coordinates.h:1076
foxit::pdf::objects::PDFStream::e_RunLengthDecode
Filter type: RunLengthDecode, which means to decompress data encoded using a byte-oriented run-length...
Definition: fs_pdfobject.h:488
foxit::pdf::objects::PDFArray::CreateFromMatrix
static PDFArray * CreateFromMatrix(const Matrix &matrix)
Create a new array object for a matrix.
foxit::pdf::objects::PDFStream
Definition: fs_pdfobject.h:448
foxit::pdf::objects::PDFDictionary::SetAtDateTime
void SetAtDateTime(const char *key, const DateTime &value)
Set a Datetime object as value element to an entry specified by key.
foxit::pdf::objects::PDFDictionary::RemoveAt
void RemoveAt(const char *key)
Remove an entry specified by key.
foxit::pdf::objects::PDFArray::AddMatrix
void AddMatrix(const Matrix &matrix)
Add a matrix to the end of current PDF array object.
CFX_WideString
WIDE STRING CLASS.
Definition: fx_string.h:1461
foxit::pdf::objects::PDFDictionary::SetAt
void SetAt(const char *key, PDFObject *pdf_object)
Set a direct PDF object (whose object number is always equal to 0) as value element to an entry speci...
foxit::pdf::objects::PDFObject::GetObjNum
uint32 GetObjNum() const
Get the indirect object number of current PDF object.
foxit::pdf::objects::PDFDictionary::SetAtInteger
void SetAtInteger(const char *key, int value)
Set a integer element to an entry specified by key.
foxit::uint32
FX_UINT32 uint32
32-bit unsigned integer.
Definition: fs_basictypes.h:195
foxit::uint64
FX_UINT64 uint64
Unsigned 64-bit integer.
Definition: fs_basictypes.h:191
foxit::pdf::objects::PDFStream::e_Crypt
Filter type: Crypt, which means to decrypt data encrypted by a security handler, reproducing the orig...
Definition: fs_pdfobject.h:513
foxit::pdf::objects::PDFObject::GetType
Type GetType() const
Get the type of current PDF object.
foxit::pdf::objects::PDFObject::GetFloat
float GetFloat() const
Get the float value of current PDF object.