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 
34 namespace foxit {
38 namespace pdf {
39 // forward declaration
40 namespace interform {
41 class Control;
42 } // namespace interform
43 class PDFDoc;
44 //class Signature;
45 
64 class GraphicsObjects : public Base {
65  public:
71  typedef enum _TextMergeOption {
86 
87  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
88  explicit GraphicsObjects(FS_HANDLE handle = NULL);
90  virtual ~GraphicsObjects();
91 
97  GraphicsObjects(const GraphicsObjects& other);
98 
107 
115  bool IsEmpty() const;
116 
124  bool operator==(const GraphicsObjects& other) const;
125 
133  bool operator!=(const GraphicsObjects& other) const;
134 
151 
171 
188 
208 
218 
235  POSITION InsertGraphicsObject(POSITION position_insert_after, graphics::GraphicsObject* graphics_object);
236 
252  bool RemoveGraphicsObject(graphics::GraphicsObject* graphics_object);
253 
270 
285  POSITION MoveGraphicsObjectByPosition(POSITION current_position, POSITION position_move_after);
286 
295 
302  int GetGraphicsObjectCount() const;
303 
313  int GetGraphicsObjectIndex(graphics::GraphicsObject* graphics_object) const;
314 
324 
342  bool GenerateContent();
343 
364  bool GenerateContent(TextMergeOption text_merge_option);
365 };
366 
412 class PDFPage FS_FINAL : public GraphicsObjects {
413  public:
419  typedef enum _ParseFlags {
424  } ParseFlags;
425 
431  typedef enum _CalcMarginMode {
436  } CalcMarginMode;
437 
443  typedef enum _FlattenOptions {
450  } FlattenOptions;
451 
457  typedef enum _BoxType {
477  e_ArtBox = 3,
483  } BoxType;
484 
490  typedef enum _Size {
496  e_SizeA2 = 3,
498  e_SizeA3 = 4,
500  e_SizeA4 = 5,
502  e_SizeA5 = 6,
504  e_SizeA6 = 7,
506  e_SizeB2 = 8,
508  e_SizeB3 = 9,
510  e_SizeB4 = 10,
512  e_SizeB5 = 11,
514  e_SizeB6 = 12
515  } Size;
516 
525  PDFPage(const PDFDoc& document, objects::PDFDictionary* page_dict);
526 
527  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
528  explicit PDFPage(FS_HANDLE handle = NULL);
529 
535  explicit PDFPage(const foxit::pdf::GraphicsObjects& other);
536 
538  ~PDFPage();
539 
545  PDFDoc GetDocument() const;
546 
553 
560  bool IsParsed() const;
561 
588  bool is_reparse = false);
589 
595  int GetIndex() const;
596 
602  float GetHeight() const;
603 
609  float GetWidth() const;
610 
618 
626 
640  Matrix GetDisplayMatrix(int left, int top, int width, int height, common::Rotation rotate);
641 
658 
659 #ifndef __EMSCRIPTEN_RENDER__
660 
665  int GetAnnotCount();
666 
675  annots::Annot GetAnnot(int index);
676 
692  annots::Annot GetAnnotAtPoint(const PointF& position, float tolerance);
693 
713  annots::Annot GetAnnotAtDevicePoint(const PointF& position, float tolerance, const Matrix* matrix = NULL);
714 
733  annots::AnnotArray GetAnnotsAtPoint(const PointF& position, float tolerance);
734 
757  annots::AnnotArray GetAnnotsAtDevicePoint(const PointF& position, float tolerance, const Matrix* matrix = NULL);
758 
808  annots::Annot AddAnnot(annots::Annot::Type type, const RectF& rect);
809 
818 
833  bool RemoveAnnot(const annots::Annot& annot);
834 
850  void MoveAnnotToFirst(const annots::Annot& annot);
851 
867  void MoveAnnotToLast(const annots::Annot& annot);
868 
884  void MoveAnnotToPrev(const annots::Annot& annot);
885 
901  void MoveAnnotToNext(const annots::Annot& annot);
902 
911  void UpdateAnnotList();
912 #endif
913 
921  bool HasTransparency();
922 
956  bool Flatten(bool for_display, uint32 options = PDFPage::e_FlattenAll);
957 #ifndef __EMSCRIPTEN_RENDER__
958 
967  bool FlattenAnnot(annots::Annot annot);
968 
994  bool SetAnnotGroup(const annots::MarkupArray& annot_array, int header_index);
995 
1011 
1027  foxit::pdf::Signature AddSignature(const foxit::RectF& rect, const foxit::WString& field_name);
1028 
1054  foxit::pdf::Signature AddSignature(const foxit::RectF& rect, const foxit::WString& field_name, foxit::pdf::Signature::SignatureType signature_type, bool to_check_permission = true);
1055 
1084  foxit::pdf::Signature AddSignatureWithExistedVDict(const foxit::RectF& rect, const foxit::WString& field_name, foxit::pdf::Signature::SignatureType signature_type, bool to_check_permission, const foxit::pdf::Signature& existed_signature);
1085 #endif
1086 
1095  bool HasWatermark();
1096 
1104  bool RemoveAllWatermarks();
1105 
1114  void SetRotation(common::Rotation rotate);
1115 
1130  void SetSize(float width, float height);
1146 
1156  void SetBox(BoxType box_type, const RectF& box);
1157 
1166  RectF GetBox(BoxType box_type);
1167 
1176  float GetUserUnitSize() const;
1177 
1189  void SetUserUnitSize(float user_unit);
1190 
1206  bool Transform(const Matrix& matrix, bool need_transform_clip_path, bool need_transform_annotations = false);
1207 
1217  bool Normalize();
1218 
1229  void SetClipRect(const RectF& clip_rect);
1230 
1243  void SetThumbnail(const common::Bitmap& thumbnail);
1244 
1258  graphics::GraphicsObject* GetGraphicsObjectAtPoint(const PointF& point, float tolerance,
1260 
1274  graphics::GraphicsObjectArray GetGraphicsObjectsAtPoint(const PointF& point, float tolerance,
1276 
1293  graphics::GraphicsObject* GetGraphicsObjectAtDevicePoint(const PointF& point, float tolerance,const Matrix* matrix ,
1295 
1312  graphics::GraphicsObjectArray GetGraphicsObjectsAtDevicePoint(const PointF& point, float tolerance,const Matrix* matrix,
1314 
1329 
1343 
1368  bool AddImage(const common::Image& image, int frame_index, const PointF& position, float width, float height,
1369  bool auto_generate_content = true);
1370 
1391  bool AddImageFromFilePath(const char* file_path, const PointF& position, float width, float height,
1392  bool auto_generate_content = true);
1393 
1414  bool AddImageFromFilePath(const wchar_t* file_path, const PointF& position, float width, float height,
1415  bool auto_generate_content = true);
1416 
1425  objects::PDFArray* GetAnnots() const;
1426 
1436 
1447 
1456  objects::PDFStream* GetThumb() const;
1457 
1469  objects::PDFObject* GetInheritedAttribute(const char* attruibute_name) const;
1470 
1476  void ClearRenderCache();
1477 
1494  RectF GetSuggestedRect(const common::Bitmap& render_result, const Matrix& render_matrix, const PointF& point) const;
1495 
1512  bool AddText(const wchar_t* text, const foxit::RectF& rect, const foxit::pdf::RichTextStyle& style, bool disable_embed_font = false);
1513 
1531  RectF AddText(const wchar_t* text, const foxit::RectF& rect, const foxit::pdf::RichTextStyle& style, int rotation, bool disable_embed_font = false);
1532 };
1533 } // namespace pdf
1534 } // namespace foxit
1535 #endif // FS_PDFPAGE_H_
1536 
Definition: fs_pdfgraphicsobject.h:241
annots::Annot AddAnnot(annots::Annot::Type type, const RectF &rect)
Add an annotation to current PDF page.
Definition: fs_pdfobject.h:422
Definition: fs_pdfpage.h:64
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_annot.h:203
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:419
RectF GetSuggestedRect(const common::Bitmap &render_result, const Matrix &render_matrix, const PointF &point) const
Get the suggested rectangle (in PDF coordinate system) for a point (in PDF coordinate system) based o...
virtual ~GraphicsObjects()
Destructor.
Page size: A5.
Definition: fs_pdfpage.h:502
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.
Definition: fs_annot.h:1656
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:467
Merge consecutive text-showing operators with equal y coordinates.
Definition: fs_pdfpage.h:77
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:1003
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 (unit is 1/72 inch).
Bleed Box for page boundary.
Definition: fs_pdfpage.h:482
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
void UpdateAnnotList()
Update the annotation list.
Flatten a PDF page without form controls.
Definition: fs_pdfpage.h:449
Calculate margin by detecting paths or images.
Definition: fs_pdfpage.h:435
SignatureType
Enumeration for signature type.
Definition: fs_signature.h:251
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:457
Definition: fs_pdfdoc.h:610
void SetRotation(common::Rotation rotate)
Set page rotation.
bool Transform(const Matrix &matrix, bool need_transform_clip_path, bool need_transform_annotations=false)
Transform a PDF page, including annotations and form fields on the page.
bool HasWatermark()
Check whether the current page has any watermark (not including Foxit PDF SDK trial watermark).
Page size: A4.
Definition: fs_pdfpage.h:500
POSITION GetGraphicsObjectPosition(graphics::GraphicsObject *graphics_object)
Get the position of the specified graphics object.
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.
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 PDF siganture 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:462
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:472
FlattenOptions
Enumeration for flatten options.
Definition: fs_pdfpage.h:443
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:510
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 (unit is 1/72 inch).
Page size: A2.
Definition: fs_pdfpage.h:496
annots::Annot GetAnnotAtDevicePoint(const PointF &position, float tolerance, const Matrix *matrix=0)
Get the annotation at a specified position, in device coordinate system.
annots::AnnotArray GetAnnotsAtPoint(const PointF &position, float tolerance)
Get all the annotations at a specified position, in PDF coordinate system.
Size
Enumeration for page size type.
Definition: fs_pdfpage.h:490
Definition: fx_basic.h:3761
No text merge.
Definition: fs_pdfpage.h:73
foxit::pdf::Signature AddSignature(const foxit::RectF &rect)
Add an ordinary signature to PDF page.
Page size: A6.
Definition: fs_pdfpage.h:504
FX_POSITION POSITION
A value used to denote the position of an element in a collection.
Definition: fs_basictypes.h:206
bool AddText(const wchar_t *text, const foxit::RectF &rect, const foxit::pdf::RichTextStyle &style, bool disable_embed_font=false)
Add text to current page.
Page size: B5.
Definition: fs_pdfpage.h:512
Page size: B3.
Definition: fs_pdfpage.h:508
Definition: fs_common.h:346
Art Box for page boundary.
Definition: fs_pdfpage.h:477
Definition: fx_basic.h:1297
annots::AnnotArray GetAnnotsAtDevicePoint(const PointF &position, float tolerance, const Matrix *matrix=0)
Get all the annotations at a specified position, in device coordinate system.
bool RemoveAllWatermarks()
Remove all watermarks.
FX_UINT32 uint32
32-bit unsigned integer.
Definition: fs_basictypes.h:196
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:412
void * FS_HANDLE
Handle type.
Definition: fs_basictypes.h:214
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:421
Definition: fs_annot.h:1867
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.
graphics::GraphicsObjectArray GetGraphicsObjectsAtRectangle(const RectF &rect, graphics::GraphicsObject::Type filter=graphics::GraphicsObject::e_TypeAll)
Get all the graphics objects whose rectangles intersect with a specified rectangle,...
Header file for PDF object related definitions and classes.
Definition: fs_basictypes.h:427
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.
bool Normalize()
Transform current PDF page by undoing any rotation and removing the offset to the page's "CropBox".
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.
TextMergeOption
Enumeration for text merge.
Definition: fs_pdfpage.h:71
Flatten all contents of a PDF page.
Definition: fs_pdfpage.h:445
Definition: fs_annot.h:996
annots::Annot GetAnnot(int index)
Get an annotation by index.
Flatten a PDF page without annotations.
Definition: fs_pdfpage.h:447
Definition: fs_pdfobject.h:809
CalcMarginMode
Enumeration for calculating margin mode.
Definition: fs_pdfpage.h:431
void ClearRenderCache()
Clear render cache.
bool operator==(const GraphicsObjects &other) const
Equal operator.
Rotation
Enumeration for rotation.
Definition: fs_common.h:57
void MoveAnnotToNext(const annots::Annot &annot)
Exchange the indexes of current annotation and its next annotation.
Foxit namespace.
Definition: fs_taggedpdf.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:506
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 ...
graphics::GraphicsObject * GetGraphicsObjectAtRectangle(const RectF &rect, graphics::GraphicsObject::Type filter=graphics::GraphicsObject::e_TypeAll) const
Get the topmost graphics object whose rectangle interasects with a specified rectangle,...
foxit::pdf::Signature AddSignatureWithExistedVDict(const foxit::RectF &rect, const foxit::WString &field_name, foxit::pdf::Signature::SignatureType signature_type, bool to_check_permission, const foxit::pdf::Signature &existed_signature)
Add a signature to PDF page with the existed "V" dictionary in the specific signature.
Page size: A3.
Definition: fs_pdfpage.h:498
#define NULL
The null-pointer value.
Definition: fx_system.h:780
Definition: fs_signature.h:99
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:423
Merge consecutive BTETs as a new one.
Definition: fs_pdfpage.h:84
Page size: letter.
Definition: fs_pdfpage.h:492
Page size: B6.
Definition: fs_pdfpage.h:514
graphics::GraphicsObject * GetGraphicsObject(POSITION position) const
Get the graphics object by position in graphics object list.
POSITION MoveGraphicsObjectByPosition(POSITION current_position, POSITION position_move_after)
Move a graphics object from a position to another position.
Definition: fs_pdfobject.h:614
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:448
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:494
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:433
~PDFPage()
Destructor.
bool IsEmpty() const
Check whether current object is empty or not.