Foxit PDF SDK
fs_pdfpage.h
Go to the documentation of this file.
1 
15 #ifndef FS_PDFPAGE_H_
16 #define FS_PDFPAGE_H_
17 
18 #include "common/fs_common.h"
19 #include "common/fs_image.h"
20 #ifndef __EMSCRIPTEN_RENDER__
21 #include "pdf/annots/fs_annot.h"
22 #endif
25 #ifndef __EMSCRIPTEN_RENDER__
26 #include "pdf/fs_signature.h"
27 #endif
28 
33 namespace foxit {
37 namespace pdf {
38 // forward declaration
39 namespace interform {
40 class Control;
41 } // namespace interform
42 class PDFDoc;
43 //class Signature;
44 
63 class GraphicsObjects : public Base {
64  public:
65  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
66  explicit GraphicsObjects(FS_HANDLE handle = NULL);
68  virtual ~GraphicsObjects();
69 
75  GraphicsObjects(const GraphicsObjects& other);
76 
85 
93  bool IsEmpty() const;
94 
102  bool operator==(const GraphicsObjects& other) const;
103 
111  bool operator!=(const GraphicsObjects& other) const;
112 
148 
165 
185 
195 
212  POSITION InsertGraphicsObject(POSITION position_insert_after, graphics::GraphicsObject* graphics_object);
213 
229  bool RemoveGraphicsObject(graphics::GraphicsObject* graphics_object);
230 
247 
254  int GetGraphicsObjectCount() const;
255 
265  int GetGraphicsObjectIndex(graphics::GraphicsObject* graphics_object) const;
266 
276 
294  bool GenerateContent();
295 };
296 
342 class PDFPage FS_FINAL : public GraphicsObjects {
343  public:
349  typedef enum _ParseFlags {
354  } ParseFlags;
355 
361  typedef enum _CalcMarginMode {
366  } CalcMarginMode;
367 
373  typedef enum _FlattenOptions {
380  } FlattenOptions;
381 
387  typedef enum _BoxType {
407  e_ArtBox = 3,
413  } BoxType;
414 
420  typedef enum _Size {
426  e_SizeA2 = 3,
428  e_SizeA3 = 4,
430  e_SizeA4 = 5,
432  e_SizeA5 = 6,
434  e_SizeA6 = 7,
436  e_SizeB2 = 8,
438  e_SizeB3 = 9,
440  e_SizeB4 = 10,
442  e_SizeB5 = 11,
444  e_SizeB6 = 12
445  } Size;
446 
455  PDFPage(const PDFDoc& document, objects::PDFDictionary* page_dict);
456 
457  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
458  explicit PDFPage(FS_HANDLE handle = NULL);
459 
465  explicit PDFPage(const foxit::pdf::GraphicsObjects& other);
466 
468  virtual ~PDFPage();
469 
475  PDFDoc GetDocument() const;
482 
489  bool IsParsed() const;
516  bool is_reparse = false);
517 
523  int GetIndex() const;
529  float GetHeight() const;
535  float GetWidth() const;
550 
564  Matrix GetDisplayMatrix(int left, int top, int width, int height, common::Rotation rotate);
565 
582 #ifndef __EMSCRIPTEN_RENDER__
583 
588  int GetAnnotCount();
589 
598  annots::Annot GetAnnot(int index);
599 
614  annots::Annot GetAnnotAtPoint(const PointF& position, float tolerance);
615 
634  annots::Annot GetAnnotAtDevicePoint(const PointF& position, float tolerance, const Matrix* matrix = NULL);
635 
685  annots::Annot AddAnnot(annots::Annot::Type type, const RectF& rect);
686 
701  bool RemoveAnnot(const annots::Annot& annot);
702 
718  void MoveAnnotToFirst(const annots::Annot& annot);
719 
735  void MoveAnnotToLast(const annots::Annot& annot);
736 
752  void MoveAnnotToPrev(const annots::Annot& annot);
753 
769  void MoveAnnotToNext(const annots::Annot& annot);
770 #endif
771 
779  bool HasTransparency();
780 
814  bool Flatten(bool for_display, uint32 options = PDFPage::e_FlattenAll);
815 #ifndef __EMSCRIPTEN_RENDER__
816 
825  bool FlattenAnnot(annots::Annot annot);
826 
852  bool SetAnnotGroup(const annots::MarkupArray& annot_array, int header_index);
853 
869 
885  foxit::pdf::Signature AddSignature(const foxit::RectF& rect, const foxit::WString& field_name);
886 
908 #endif
909 
918  bool HasWatermark();
919 
927  bool RemoveAllWatermarks();
928 
937  void SetRotation(common::Rotation rotate);
938 
953  void SetSize(float width, float height);
969 
979  void SetBox(BoxType box_type, const RectF& box);
980 
989  RectF GetBox(BoxType box_type);
990 
999  float GetUserUnitSize() const;
1000 
1012  void SetUserUnitSize(float user_unit);
1013 
1027  bool Transform(const Matrix& matrix, bool need_transform_clip_path);
1028 
1039  void SetClipRect(const RectF& clip_rect);
1040 
1052  void SetThumbnail(const common::Bitmap& thumbnail);
1053 
1067  graphics::GraphicsObject* GetGraphicsObjectAtPoint(const PointF& point, float tolerance,
1069 
1083  graphics::GraphicsObjectArray GetGraphicsObjectsAtPoint(const PointF& point, float tolerance,
1085 
1102  graphics::GraphicsObject* GetGraphicsObjectAtDevicePoint(const PointF& point, float tolerance,const Matrix* matrix ,
1104 
1121  graphics::GraphicsObjectArray GetGraphicsObjectsAtDevicePoint(const PointF& point, float tolerance,const Matrix* matrix,
1147  bool AddImage(const common::Image& image, int frame_index, const PointF& position, float width, float height,
1148  bool auto_generate_content = true);
1149 
1170  bool AddImageFromFilePath(const char* file_path, const PointF& position, float width, float height,
1171  bool auto_generate_content = true);
1172 
1193  bool AddImageFromFilePath(const wchar_t* file_path, const PointF& position, float width, float height,
1194  bool auto_generate_content = true);
1195 
1203  objects::PDFArray* GetAnnots() const;
1204 
1213 
1223 
1231  objects::PDFStream* GetThumb() const;
1232 
1244  objects::PDFObject* GetInheritedAttribute(const char* attruibute_name) const;
1245 
1251  void ClearRenderCache();
1252 };
1253 } // namespace pdf
1254 } // namespace foxit
1255 #endif // FS_PDFPAGE_H_
1256 
Definition: fs_pdfgraphicsobject.h:241
annots::Annot AddAnnot(annots::Annot::Type type, const RectF &rect)
Add an annotation to PDF page.
Definition: fs_pdfobject.h:385
Definition: fs_pdfpage.h:63
virtual ~PDFPage()
Destructor.
bool AddImageFromFilePath(const char *file_path, const PointF &position, float width, float height, bool auto_generate_content=true)
Add an image to current page from file path.
void SetUserUnitSize(float user_unit)
Set the user unit.
Definition: fs_image.h:36
POSITION GetLastGraphicsObjectPosition(graphics::GraphicsObject::Type filter=graphics::GraphicsObject::e_TypeAll) const
Get the position of last graphics object in graphics object list, based on type filter.
ParseFlags
Enumeration for parsing flags used for PDF page.
Definition: fs_pdfpage.h:349
virtual ~GraphicsObjects()
Destructor.
Page size: A5.
Definition: fs_pdfpage.h:432
bool GenerateContent()
Generate contents of current graphics objects.
Type
Enumeration for PDF graphics object type.
Definition: fs_pdfgraphicsobject.h:378
float GetUserUnitSize() const
Get the user unit.
graphics::GraphicsObjectArray GetGraphicsObjectsAtPoint(const PointF &point, float tolerance, graphics::GraphicsObject::Type filter=graphics::GraphicsObject::e_TypeAll)
Get all the graphics objects in specified point, with specified type filter.
bool RemoveGraphicsObject(graphics::GraphicsObject *graphics_object)
Remove a graphics object.
common::Bitmap LoadThumbnail()
Load the thumbnail bitmap.
objects::PDFDictionary * GetResources() const
Get the PDF dictionary of "Resources".
void MoveAnnotToPrev(const annots::Annot &annot)
Exchange the indexes of current annotation and its previous annotation.
Crop Box for page boundary.
Definition: fs_pdfpage.h:397
Definition: fx_coordinates.h:30
bool Flatten(bool for_display, uint32 options=PDFPage::e_FlattenAll)
Flatten current PDF page: annotations or form fields may be made to be a part of the page contents ac...
Type
Enumeration for PDF annotation type.
Definition: fs_annot.h:761
int GetGraphicsObjectCount() const
Get the count of graphics objects in graphics object list.
void SetThumbnail(const common::Bitmap &thumbnail)
Set page thumbnail.
float GetHeight() const
Get the page height.
Bleed Box for page boundary.
Definition: fs_pdfpage.h:412
POSITION InsertGraphicsObject(POSITION position_insert_after, graphics::GraphicsObject *graphics_object)
Insert a graphics object after the specified position.
WIDE STRING CLASS.
Definition: fx_string.h:1452
Flatten a PDF page without form controls.
Definition: fs_pdfpage.h:379
Calculate margin by detecting paths or images.
Definition: fs_pdfpage.h:365
SignatureType
Enumeration for signature type.
Definition: fs_signature.h:239
graphics::GraphicsObject * GetGraphicsObjectAtDevicePoint(const PointF &point, float tolerance, const Matrix *matrix, graphics::GraphicsObject::Type filter=graphics::GraphicsObject::e_TypeAll) const
Get the topmost graphics object in specified point in device coordinate system, with specified type f...
objects::PDFObject * GetContents() const
Get the PDF object of "Contents".
BoxType
Enumeration for page box type.
Definition: fs_pdfpage.h:387
Definition: fs_pdfdoc.h:389
void SetRotation(common::Rotation rotate)
Set page rotation.
bool HasWatermark()
Check whether the current page has any watermark (not including Foxit PDF SDK trial watermark).
Page size: A4.
Definition: fs_pdfpage.h:430
GraphicsObjects & operator=(const GraphicsObjects &other)
Assign operator.
Matrix GetDisplayMatrix(int left, int top, int width, int height, common::Rotation rotate)
Get the display matrix of PDF page, from PDF coordinate system to targeted device coordinate system.
bool operator!=(const GraphicsObjects &other) const
Not equal operator.
bool Transform(const Matrix &matrix, bool need_transform_clip_path)
Transform a PDF page, including annotations and form fields on the page.
Header file for image and bitmap related definitions and classes.
Represents all graphics object types, only used as filter.
Definition: fs_pdfgraphicsobject.h:380
Header file for LTV verifier related definitions and classes.
PDFPage(const PDFDoc &document, objects::PDFDictionary *page_dict)
Constructor, from a PDF dictionary which represents a PDF page and the PDF document which contains th...
Media Box for page boundary.
Definition: fs_pdfpage.h:392
PDFDoc GetDocument() const
Get the PDF document, to which current PDF page belongs.
RectF CalcContentBBox(CalcMarginMode mode)
Calculate the content area of PDF page.
int GetIndex() const
Get page index.
bool IsParsed() const
Check if current page has been parsed or not.
Trim Box for page boundary.
Definition: fs_pdfpage.h:402
FlattenOptions
Enumeration for flatten options.
Definition: fs_pdfpage.h:373
bool RemoveAnnot(const annots::Annot &annot)
Remove an annotation.
annots::Annot GetAnnotAtPoint(const PointF &position, float tolerance)
Get the annotation at a specified position, in PDF coordinate system.
RectF GetBox(BoxType box_type)
Get page box.
Page size: B4.
Definition: fs_pdfpage.h:440
int GetAnnotCount()
Get the count of annotations.
bool HasTransparency()
Check whether current PDF page has transparency or not.
objects::PDFStream * GetThumb() const
Get the PDF stream of "Thumb".
bool SetAnnotGroup(const annots::MarkupArray &annot_array, int header_index)
Group all the input markup annotations together.
Header file for annotation related definitions and classes.
float GetWidth() const
Get the page width.
Page size: A2.
Definition: fs_pdfpage.h:426
annots::Annot GetAnnotAtDevicePoint(const PointF &position, float tolerance, const Matrix *matrix=0)
Get the annotation at a specified position, in device coordination system.
Size
Enumeration for page size type.
Definition: fs_pdfpage.h:420
Definition: fx_basic.h:3752
foxit::pdf::Signature AddSignature(const foxit::RectF &rect)
Add an ordinary signature to PDF page.
Page size: A6.
Definition: fs_pdfpage.h:434
FX_POSITION POSITION
A value used to denote the position of an element in a collection.
Definition: fs_basictypes.h:208
Page size: B5.
Definition: fs_pdfpage.h:442
Page size: B3.
Definition: fs_pdfpage.h:438
Definition: fs_common.h:568
Art Box for page boundary.
Definition: fs_pdfpage.h:407
Definition: fx_basic.h:1288
bool RemoveAllWatermarks()
Remove all watermarks.
FX_UINT32 uint32
32-bit unsigned integer.
Definition: fs_basictypes.h:198
bool FlattenAnnot(annots::Annot annot)
Flatten an annotation: the annotation is made to be a part of the page contents and be removed then.
POSITION GetFirstGraphicsObjectPosition(graphics::GraphicsObject::Type filter=graphics::GraphicsObject::e_TypeAll) const
Get the position of first graphics object in graphics object list, based on type filter.
Definition: fs_pdfpage.h:342
void * FS_HANDLE
Handle type.
Definition: fs_basictypes.h:216
Header file for common definitions and classes.
common::Rotation GetRotation() const
Get the page rotation.
Parsing flag for normal mode, which means to parse all the contents in a PDF page.
Definition: fs_pdfpage.h:351
Definition: fs_annot.h:1580
objects::PDFArray * GetAnnots() const
Get the PDF array of "Annots".
void MoveAnnotToLast(const annots::Annot &annot)
Change specified annotation to be the last one of all annotations.
Header file for PDF object related definitions and classes.
Definition: fs_basictypes.h:399
graphics::GraphicsObjectArray GetGraphicsObjectsAtDevicePoint(const PointF &point, float tolerance, const Matrix *matrix, graphics::GraphicsObject::Type filter=graphics::GraphicsObject::e_TypeAll)
Get all the graphics objects in specified point in device coordinate system, with specified type filt...
bool RemoveGraphicsObjectByPosition(POSITION position)
Remove a graphics object by position.
common::Progressive StartParse(uint32 flags=PDFPage::e_ParsePageNormal, common::PauseCallback *pause=0, bool is_reparse=false)
Start to parse current page.
graphics::GraphicsObject * GetGraphicsObjectAtPoint(const PointF &point, float tolerance, graphics::GraphicsObject::Type filter=graphics::GraphicsObject::e_TypeAll) const
Get the topmost graphics object in specified point, with specified type filter.
Flatten all contents of a PDF page.
Definition: fs_pdfpage.h:375
Definition: fs_annot.h:754
annots::Annot GetAnnot(int index)
Get an annotation by index.
Flatten a PDF page without annotations.
Definition: fs_pdfpage.h:377
Definition: fs_pdfobject.h:763
CalcMarginMode
Enumeration for calculating margin mode.
Definition: fs_pdfpage.h:361
void ClearRenderCache()
Clear render cache.
bool operator==(const GraphicsObjects &other) const
Equal operator.
Rotation
Enumeration for rotation.
Definition: fs_common.h:344
void MoveAnnotToNext(const annots::Annot &annot)
Exchange the indexes of current annotation and its next annotation.
Foxit namespace.
Definition: fs_compare.h:27
Definition: fs_pdfobject.h:55
int GetGraphicsObjectIndex(graphics::GraphicsObject *graphics_object) const
Get the index of a specified graphics object in graphics object list.
void SetSize(float width, float height)
Set page width and height.
void MoveAnnotToFirst(const annots::Annot &annot)
Change specified annotation to be the first one of all annotations.
POSITION GetPrevGraphicsObjectPosition(POSITION position, graphics::GraphicsObject::Type filter=graphics::GraphicsObject::e_TypeAll) const
Get the position of previous graphics object in graphics object list, based on type filter and specif...
Page size: B2.
Definition: fs_pdfpage.h:436
objects::PDFObject * GetInheritedAttribute(const char *attruibute_name) const
Get the PDF object for specified attribute which may be inherited from the ancestor node in the page ...
Page size: A3.
Definition: fs_pdfpage.h:428
#define NULL
The null-pointer value.
Definition: fx_system.h:767
Definition: fs_signature.h:93
Header file for PDF graphics object related definitions and classes.
Definition: fx_coordinates.h:1076
Parsing flag for text-only mode.
Definition: fs_pdfpage.h:353
Page size: letter.
Definition: fs_pdfpage.h:422
Page size: B6.
Definition: fs_pdfpage.h:444
graphics::GraphicsObject * GetGraphicsObject(POSITION position) const
Get the graphics object by position in graphics object list.
Definition: fs_pdfobject.h:575
void SetClipRect(const RectF &clip_rect)
Set clip rectangle for all graphics objects on current PDF page.
void SetBox(BoxType box_type, const RectF &box)
Set page box.
Definition: fs_image.h:430
POSITION GetNextGraphicsObjectPosition(POSITION position, graphics::GraphicsObject::Type filter=graphics::GraphicsObject::e_TypeAll) const
Get the position of next graphics object in graphics object list, based on type filter and specified ...
objects::PDFDictionary * GetDict() const
Get the page dictionary.
Page size: legal.
Definition: fs_pdfpage.h:424
bool AddImage(const common::Image &image, int frame_index, const PointF &position, float width, float height, bool auto_generate_content=true)
Add an image to current page.
Definition: fx_coordinates.h:771
Calculate margin according to bounding box of all contents.
Definition: fs_pdfpage.h:363
bool IsEmpty() const
Check whether current object is empty or not.