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 {
66  e_Boolean = 1,
68  e_Number = 2,
70  e_String = 3,
72  e_Name = 4,
74  e_Array = 5,
78  e_Stream = 7,
80  e_Null = 8,
83  } Type;
84 
94  static PDFObject* CreateFromBoolean(bool boolean_value);
95 
105  static PDFObject* CreateFromFloat(float float_value);
106 
116  static PDFObject* CreateFromInteger(int integer_value);
117 
127  static PDFObject* CreateFromString(const wchar_t* string_value);
128 
138  static PDFObject* CreateFromName(const char* name);
139 
154  static PDFObject* CreateFromDateTime(const DateTime& date_time);
155 
173  static PDFObject* CreateReference(PDFDoc document, uint32 object_number);
174 
175 #if !defined(_SWIG_IOS_) && !defined(_SWIG_MACOC_)
176 
187  void Release();
188 #endif
189 
197  PDFObject* CloneObject() const;
198 
209  PDFObject* DeepCloneObject() const;
210 
219  bool IsIdentical(PDFObject* pdf_obj) const;
220 
227  Type GetType() const;
228 
239  uint32 GetObjNum() const;
240 
248  int GetInteger() const;
249 
257  float GetFloat() const;
258 
266  bool GetBoolean() const;
267 
277  Matrix GetMatrix() const;
278 
288  RectF GetRect() const;
289 
298  PDFObject* GetDirectObject() const;
299 
309  DateTime GetDateTime() const;
310 
320  String GetName() const;
321 
338  String GetString() const;
339 
356  WString GetWideString() const;
357 
367  PDFArray* GetArray();
368 
379 
389  PDFStream* GetStream();
390 
391  protected:
392  ~PDFObject() {}
393 
394  private:
395  PDFObject(const PDFObject&);
396  PDFObject &operator = (const PDFObject& object);
397 };
398 
407 class PDFStream FS_FINAL : public PDFObject {
408  public:
416  typedef enum _Filter {
418  e_Unknown = -1,
472  e_Crypt = 10
473  } Filter;
474 
490  static PDFStream* Create(PDFDictionary* dictionary);
491 
498 
506 
516  uint64 GetDataSize(bool is_raw_data);
517 
536  bool GetData(bool is_raw_data, size_t size, void* out_buffer);
537 
546  void SetData(const void* buffer, size_t size);
547 
562  void ImportData(common::file::ReaderCallback* file_read, Filter stream_filter);
563 
580  common::file::ReaderCallback* ExportData(bool is_raw_data);
581 
582  private:
583  PDFStream(const PDFStream&);
584  PDFStream &operator = (const PDFStream& stream);
585 };
586 
597 class PDFArray FS_FINAL : public PDFObject {
598  public:
606  static PDFArray* Create();
607 
617  static PDFArray* CreateFromMatrix(const Matrix& matrix);
618 
628  static PDFArray* CreateFromRect(const RectF& rect);
629 
635  int GetElementCount() const;
636 
645  PDFObject* GetElement(int index) const;
646 
654  void AddElement(PDFObject* element);
655 
663  void AddBoolean(bool boolean_value);
664 
672  void AddDateTime(const DateTime& date_time);
673 
681  void AddFloat(float float_value);
682 
690  void AddInteger(int integer_value);
691 
699  void AddMatrix(const Matrix& matrix);
700 
708  void AddRect(const RectF& rect);
709 
718  void AddName(const char* name);
719 
728  void AddString(const wchar_t* new_string);
729 
744  void InsertAt(int index, PDFObject* element);
745 
756  void SetAt(int index, PDFObject* element);
757 
767  void RemoveAt(int index);
768 
769  private:
770  PDFArray(const PDFArray&);
771  PDFArray &operator = (const PDFArray& array_object);
772 };
773 
785 class PDFDictionary FS_FINAL : public PDFObject {
786  public:
794  static PDFDictionary* Create();
795 
803  bool HasKey(const char* key) const;
804 
812  PDFObject* GetElement(const char* key) const;
813 
823  POSITION MoveNext(POSITION position);
824 
832  String GetKey(POSITION position) const;
833 
841  PDFObject* GetValue(POSITION position) const;
842 
855  void SetAt(const char* key, PDFObject* pdf_object);
856 
871  void SetAtReference(const char* key, PDFObject* pdf_object, PDFDoc document);
872 
881  void SetAtBoolean(const char* key, bool value);
882 
891  void SetAtDateTime(const char* key, const DateTime& value);
892 
901  void SetAtFloat(const char* key, float value);
902 
911  void SetAtInteger(const char* key, int value);
912 
921  void SetAtMatrix(const char* key, const Matrix& value);
922 
931  void SetAtRect(const char* key, const RectF& value);
932 
941  void SetAtName(const char* key, const char* value);
942 
953  void SetAtString(const char* key, const char* value);
954 
965  void SetAtString(const char* key, const wchar_t* value);
966 
974  void RemoveAt(const char* key);
975 
976  private:
978  PDFDictionary &operator = (const PDFDictionary& dictionary);
979 };
980 
981 } // namespace objects
982 } // namespace pdf
983 } // namespace foxit
984 #endif // FS_PDFOBJECT_H_
985 
static PDFObject * CreateFromFloat(float float_value)
Create a PDF object from a float number.
PDF string object.
Definition: fs_pdfobject.h:70
Definition: fs_pdfobject.h:407
void SetAtRect(const char *key, const RectF &value)
Set a rectangle object as value element to an entry specified by key.
uint32 GetObjNum() const
Get the indirect object number of current PDF object.
static PDFArray * CreateFromMatrix(const Matrix &matrix)
Create a new array object for a matrix.
static PDFDictionary * Create()
Create a new dictionary object.
int GetElementCount() const
Get the count of elements.
void AddElement(PDFObject *element)
Add a PDF object to the end of current PDF array object.
CFX_Object Object
Object type.
Definition: fs_basictypes.h:217
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...
void SetAtBoolean(const char *key, bool value)
Set boolean element an entry specified by key.
PDFObject * GetValue(POSITION position) const
Get the value element of an entry specified by position.
Definition: fs_basictypes.h:430
void SetData(const void *buffer, size_t size)
Set stream data.
Filter type: JPXDecode, which means to decompress data encoded using the wavelet-based JPEG2000 stand...
Definition: fs_pdfobject.h:467
Filter type: CCITTFaxDecode, which means to decompress data encoded using the CCITT facsimile standar...
Definition: fs_pdfobject.h:452
void SetAtName(const char *key, const char *value)
Set a string (as PDF name object) as value element to an entry specified by key.
void SetAtString(const char *key, const char *value)
Set a string as value element to an entry specified by key.
bool IsIdentical(PDFObject *pdf_obj) const
Check if input PDF object is identical with current PDF object.
void SetAtFloat(const char *key, float value)
Set a float element to an entry specified by key.
Header file for file operation related definitions and functions.
No need to decode the stream data.
Definition: fs_pdfobject.h:420
static PDFObject * CreateReference(PDFDoc document, uint32 object_number)
Create a reference for an indirect object.
PDFObject * GetDirectObject() const
Get the direct object of current PDF object.
File reading interface.
Definition: fx_stream.h:566
Filter type: JBIG2Decode, which means to decompress data encoded using the JBIG2 standard,...
Definition: fs_pdfobject.h:457
PDFDictionary * GetDict()
Get the PDF dictionary object of current PDF object.
WIDE STRING CLASS.
Definition: fx_string.h:1452
uint64 GetDataSize(bool is_raw_data)
Get the size of stream data, in bytes.
String GetKey(POSITION position) const
Get the key of an entry specified by position.
FX_UINT64 uint64
Unsigned 64-bit integer.
Definition: fs_basictypes.h:192
PDFObject * GetElement(const char *key) const
Get the value element of an entry with specified key.
void AddDateTime(const DateTime &date_time)
Add a date time to the end of current PDF array object.
Filter
Enumeration for stream filter type.
Definition: fs_pdfobject.h:416
static PDFArray * CreateFromRect(const RectF &rect)
Create a new array object for a rectangle.
Definition: fs_pdfdoc.h:389
static PDFArray * Create()
Create a new array object.
PDF array object.
Definition: fs_pdfobject.h:74
void RemoveAt(const char *key)
Remove an entry specified by key.
void SetAtDateTime(const char *key, const DateTime &value)
Set a Datetime object as value element to an entry specified by key.
common::file::ReaderCallback * ExportData(bool is_raw_data)
Export stream data.
static PDFObject * CreateFromDateTime(const DateTime &date_time)
Create a PDF object from date time.
Filter type: LZWDecode, which means to decompress data encoded using the LZW (Lempel-Ziv-Welch) adapt...
Definition: fs_pdfobject.h:435
void AddBoolean(bool boolean_value)
Add a boolean value to the end of current PDF array object.
RectF GetRect() const
Get the rectangle value of current PDF object.
void AddString(const wchar_t *new_string)
Add a string as PDF string object to the end of current PDF array object.
void Release()
Release a newly created PDF object or a clone PDF object, which is not related to PDF document or oth...
Filter type: ASCII85Decode, which means to decode data encoded in an ASCII base-85 representation,...
Definition: fs_pdfobject.h:430
WString GetWideString() const
Get the wide string value of current PDF object.
String GetName() const
Get the name value of current PDF object.
PDF name object.
Definition: fs_pdfobject.h:72
PDFObject * CloneObject() const
Clone current PDF object and get the cloned PDF object.
FX_POSITION POSITION
A value used to denote the position of an element in a collection.
Definition: fs_basictypes.h:206
void SetAt(int index, PDFObject *element)
Set a new PDF object at a specified position in current PDF array object.
static PDFStream * Create(PDFDictionary *dictionary)
Create a new stream object based on a dictionary.
PDF stream object.
Definition: fs_pdfobject.h:78
void AddName(const char *name)
Add a string as PDF name object to the end of current PDF array object.
FX_UINT32 uint32
32-bit unsigned integer.
Definition: fs_basictypes.h:196
Filter type: RunLengthDecode, which means to decompress data encoded using a byte-oriented run-length...
Definition: fs_pdfobject.h:447
Filter type: DCTDecode, which means to decompress data encoded using a DCT (discrete cosine transform...
Definition: fs_pdfobject.h:462
bool GetBoolean() const
Get the boolean value of current PDF object.
static PDFObject * CreateFromString(const wchar_t *string_value)
Create a PDF object from string.
PDF null object.
Definition: fs_pdfobject.h:80
Header file for common definitions and classes.
static PDFObject * CreateFromInteger(int integer_value)
Create a PDF object from a integer number.
void AddRect(const RectF &rect)
Add a rectangle to the end of current PDF array object.
void AddInteger(int integer_value)
Add an integer value to the end of current PDF array object.
PDF boolean object.
Definition: fs_pdfobject.h:66
PDFDictionary * GetDictionary()
Get the PDF dictionary object associated to current PDF stream object.
PDFStream * GetStream()
Get the PDF stream object of current PDF object.
Invalid PDF object type.
Definition: fs_pdfobject.h:64
static PDFObject * CreateFromBoolean(bool boolean_value)
Create a PDF object from a boolean value.
DateTime GetDateTime() const
Get the date time value of current PDF object.
void RemoveAt(int index)
Remove an element in a specified position (by index) from current PDF array object.
void SetAtMatrix(const char *key, const Matrix &value)
Set a matrix object as value element to an entry specified by key.
Type GetType() const
Get the type of current PDF object.
Definition: fs_pdfobject.h:785
int GetInteger() const
Get the integer value of current PDF object.
PDFArray * GetArray()
Get the PDF array object of current PDF object.
Foxit namespace.
Definition: fs_compare.h:27
Definition: fs_pdfobject.h:55
Filter type: ASCIIHexDecode, which means to decode data encoded in an ASCII hexadecimal representatio...
Definition: fs_pdfobject.h:425
void AddMatrix(const Matrix &matrix)
Add a matrix to the end of current PDF array object.
PDF number object.
Definition: fs_pdfobject.h:68
BYTE STRING CLASS.
Definition: fx_string.h:317
Matrix GetMatrix() const
Get the matrix value of current PDF object.
POSITION MoveNext(POSITION position)
Move to the position of first or the next entry.
void ImportData(common::file::ReaderCallback *file_read, Filter stream_filter)
Import stream data.
void SetAtInteger(const char *key, int value)
Set a integer element to an entry specified by key.
bool HasKey(const char *key) const
Check whether there is an entry with specified key in current dictionary or not.
void InsertAt(int index, PDFObject *element)
Insert a PDF object to a specified position in current PDF array object.
PDFObject * GetElement(int index) const
Get a specified element by index.
Filter type: FlateDecode, which means to decompress data encoded using the zlib/deflate compression m...
Definition: fs_pdfobject.h:440
bool GetData(bool is_raw_data, size_t size, void *out_buffer)
Get stream data.
Definition: fx_coordinates.h:1076
String GetString() const
Get the string value of current PDF object.
Filter type: Crypt, which means to decrypt data encrypted by a security handler, reproducing the orig...
Definition: fs_pdfobject.h:472
Definition: fs_pdfobject.h:597
float GetFloat() const
Get the float value of current PDF object.
Filter GetStreamFilter()
Get the type of stream filter which indicate how the stream data must be decoded before the data is u...
PDF dictionary object.
Definition: fs_pdfobject.h:76
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...
void AddFloat(float float_value)
Add a float value to the end of current PDF array object.
Unknown filter type.
Definition: fs_pdfobject.h:418
PDF reference object.
Definition: fs_pdfobject.h:82
Definition: fx_coordinates.h:771
static PDFObject * CreateFromName(const char *name)
Create a PDF object from a string which represents a name.
PDFObject * DeepCloneObject() const
Clone current PDF object and get the cloned PDF object.
Type
Enumeration for PDF object type.
Definition: fs_pdfobject.h:62