Foxit PDF SDK
fs_pdfgraphicsobject.h
Go to the documentation of this file.
1 
15 #ifndef FS_PDFGRAPHICSOBJECT_H_
16 #define FS_PDFGRAPHICSOBJECT_H_
17 
18 #include "common/fs_common.h"
19 #include "common/file/fs_file.h"
20 #include "common/fs_image.h"
22 
28 namespace foxit {
29 namespace pdf {
30 namespace graphics {
31 class TextObject;
32 class FormXObject;
33 class ImageObject;
34 class PathObject;
35 class ShadingObject;
36 } // namespace graphics
37 class PDFPage;
38 class GraphicsObjects;
39 class LayerNodeArray;
40 class LayerTree;
41 } // namespace pdf
42 
46 namespace pdf {
50 namespace graphics {
59 class MarkedContent FS_FINAL : public Object {
60  public:
63 
72  bool HasTag(const char* tag_name);
81  int GetItemCount() const;
93  String GetItemTagName(int index) const;
102  int GetItemMCID(int index) const;
125  int AddItem(const char* tag_name, objects::PDFDictionary* property_dict = NULL);
133  bool RemoveItem(const char* tag_name);
134 
135  private:
136  MarkedContent(const MarkedContent& markedcontent);
137  MarkedContent &operator = (const MarkedContent& markedcontent);
138 };
139 
154 class GraphicsObject : public Object {
155  public:
161  typedef enum _BlendMode {
284  } BlendMode;
285 
291  typedef enum _Type {
304  } Type;
305 
306 
307 #if !defined(_SWIG_IOS_) && !defined(_SWIG_MACOC_)
308 
314  void Release();
315 #endif
316 
323  Type GetType() const;
324 
331  RectF GetRect() const;
332 
338  bool HasTransparency();
339 
347  ARGB GetStrokeColor() const;
348 
356  ARGB GetFillColor() const;
357 
374  void SetStrokeColor(ARGB color);
375 
393  void SetFillColor(ARGB color);
394 
406  void SetFillOpacity(float opacity);
407 
419  void SetStrokeOpacity(float opacity);
420 
427  float GetFillOpacity() const;
428 
435  float GetStrokeOpacity()const;
436 
443  Matrix GetMatrix() const;
444 
455  void SetMatrix(const Matrix& matrix);
456 
469  bool Transform(const Matrix& matrix, bool need_transform_clippath);
470 
482 
491 
506  void SetGraphState(const common::GraphState& graph_state);
507 
514  BlendMode GetBlendMode() const;
515 
527  void SetBlendMode(BlendMode blend_mode);
528 
534  int GetClipPathCount() const;
535 
545  common::Path GetClipPath(int index) const;
546 
556  common::FillMode GetClipPathFillMode(int index) const;
557 
570  bool AddClipPath(const common::Path& path, common::FillMode fill_mode);
571 
583  bool RemoveClipPath(int index);
584 
590  int GetClipTextObjectCount() const;
591 
600  TextObject* GetClipTextObject(int index) const;
601 
612  bool AddClipTextObject(TextObject* textobject);
613 
625  bool RemoveClipTextObject(int index);
626 
632  RectF GetClipRect() const;
633 
646  void SetClipRect(const RectF& clip_rect);
647 
656  bool ClearClips();
657 
664 
673  LayerNodeArray GetLayers(const LayerTree& layer_tree);
674 
681  TextObject* GetTextObject() const;
682 
689  FormXObject* GetFormXObject() const;
690 
697  ImageObject* GetImageObject() const;
698 
705  PathObject* GetPathObject() const;
706 
714 
727  void Rotate(int angle);
728  protected:
729  ~GraphicsObject() {}
730 
731  private:
732  GraphicsObject(const GraphicsObject& graphicsobject);
733  GraphicsObject &operator = (const GraphicsObject& graphicsobject);
734 };
735 
738 
740 class TextState FS_FINAL : public Object {
741  public:
747  typedef enum _Mode {
764  } Mode;
765 
766 
784  const PointF& origin_position, float textmatrix[4]) {
785  this->version = version;
786  this->font = font;
787  this->font_size = font_size;
788  this->charspace = charspace;
789  this->wordspace = wordspace;
790  this->textmode = textmode;
791  this->origin_position = origin_position;
792  for (int i=0; i < 4; i++)
793  this->textmatrix[i] = textmatrix[i];
794  }
795 
798  :version(1)
799  , font_size(0.0f)
800  , charspace(0.0f)
801  , wordspace(0.0f)
804  this->textmatrix[0] = 1;
805  this->textmatrix[1] = 0;
806  this->textmatrix[2] = 0;
807  this->textmatrix[3] = 1;
808  }
809 
815  TextState(const TextState& state) {
816  version = state.version;
817  font = state.font;
818  font_size = state.font_size;
819  charspace = state.charspace;
820  wordspace = state.wordspace;
821  textmode = state.textmode;
823  for (int i=0; i < 4; i++)
824  textmatrix[i] = state.textmatrix[i];
825  }
826 
834  TextState &operator = (const TextState& state) {
835  version = state.version;
836  font = state.font;
837  font_size = state.font_size;
838  charspace = state.charspace;
839  wordspace = state.wordspace;
840  textmode = state.textmode;
842  for (int i=0; i < 4; i++)
843  textmatrix[i] = state.textmatrix[i];
844  return (*this);
845  }
846 
863  void Set(uint32 version, const common::Font& font, float font_size, float charspace, float wordspace,
864  Mode textmode, const PointF& origin_position, float textmatrix[4]) {
865  this->version = version;
866  this->font = font;
867  this->font_size = font_size;
868  this->charspace = charspace;
869  this->wordspace = wordspace;
870  this->textmode = textmode;
871  this->origin_position = origin_position;
872  for (int i=0; i < 4; i++)
873  this->textmatrix[i] = textmatrix[i];
874  }
875 
885 
891 
896  float font_size;
905  float charspace;
906 
917  float wordspace;
918 
926 
933 
939  float textmatrix[4];
940 };
941 
950 class ImageObject FS_FINAL : public GraphicsObject {
951  public:
957  typedef enum _ColorSpace {
984  } ColorSpace;
985 
986 
1000  static ImageObject* Create(const PDFDoc& document);
1001 
1016  void SetBitmap(const common::Bitmap& bitmap, const common::Bitmap& mask = common::Bitmap());
1017 
1035  void SetImage(const common::Image& image, int frame_index);
1036 
1054  common::Bitmap CloneBitmap(const GraphicsObjects& graphics_objects);
1055 
1062  ColorSpace GetColorSpace() const;
1063 
1070  objects::PDFStream* GetStream() const;
1071 
1077  bool IsImageMask() const;
1078 
1092  objects::PDFObject* GetMask() const;
1093 
1094  private:
1095  ~ImageObject() {}
1096 
1097  private:
1098  ImageObject(const ImageObject& imageobject);
1099  ImageObject &operator = (const ImageObject& imageobject);
1100 
1101 };
1102 
1111 class TextObject FS_FINAL : public GraphicsObject {
1112  public:
1123  static TextObject* Create();
1124 
1130  WString GetText() const;
1131 
1145  void SetText(const wchar_t* text);
1146 
1154  TextState GetTextState(const PDFPage& page) const;
1155 
1170  void SetTextState(const PDFPage& page, const TextState& text_state, bool is_italic, int weight);
1171 
1177  int GetCharCount() const;
1178 
1187  PointF GetCharPos(int index) const;
1188 
1197  float GetCharWidthByIndex(int index) const;
1198 
1207  float GetCharHeightByIndex(int index) const;
1208 
1209  private:
1210  ~TextObject() {}
1211 
1212  private:
1213  TextObject(const TextObject& textobject);
1214  TextObject &operator = (const TextObject& textobject);
1215 };
1216 
1227 class PathObject FS_FINAL : public GraphicsObject {
1228  public:
1239  static PathObject* Create();
1240 
1252  static PathObject* CreateFromTextObject(const PDFPage& page, TextObject* text_obj);
1253 
1260  common::FillMode GetFillMode() const;
1272  void SetFillMode(common::FillMode fill_mode);
1279  bool GetStrokeState() const;
1291  void SetStrokeState(bool is_stroke);
1298  common::Path GetPathData() const;
1299 
1310  void SetPathData(const common::Path& path_data);
1311 
1312  private:
1313  ~PathObject() {}
1314 
1315  private:
1316  PathObject(const PathObject& pathobject);
1317  PathObject &operator = (const PathObject& pathobject);
1318 };
1319 
1331 class FormXObject FS_FINAL : public GraphicsObject {
1332  public:
1346  static FormXObject* Create(const PDFDoc& document);
1347 
1354  objects::PDFStream* GetStream() const;
1355 
1379  bool ImportPageContent(const PDFPage& source_page, bool is_annots_included);
1380 
1381  private:
1382  ~FormXObject() {}
1383 
1384  private:
1385  FormXObject(const FormXObject& formxobject);
1386  FormXObject &operator = (const FormXObject& formxobject);
1387 
1388 };
1389 
1396 class ShadingObject FS_FINAL : public GraphicsObject {
1397  public:
1405 
1406  private:
1407  ~ShadingObject() {}
1408 
1409  private:
1410  ShadingObject(const ShadingObject& shadingobject);
1411  ShadingObject &operator = (const ShadingObject& shadingobject);
1412 
1413 };
1414 } // namespace graphics
1415 } // namespace pdf
1416 } // namespace foxit
1417 #endif // FS_PDFGRAPHICSOBJECT_H_
1418 
Definition: fs_pdfgraphicsobject.h:154
common::FillMode GetClipPathFillMode(int index) const
Get the fill mode of a path clip by index.
ShadingObject * GetShadingObject() const
Get the shading graphics object if current graphics object represents a shading object.
TextState(uint32 version, const common::Font &font, float font_size, float charspace, float wordspace, Mode textmode, const PointF &origin_position, float textmatrix[4])
Constructor, with parameters.
Definition: fs_pdfgraphicsobject.h:783
float wordspace
Word spacing (only apply to space character).
Definition: fs_pdfgraphicsobject.h:917
int GetClipPathCount() const
Get the count of path clip.
Color space: Invalid.
Definition: fs_pdfgraphicsobject.h:959
bool HasTransparency()
Check whether current graphics object has transparency or not.
Definition: fs_pdfobject.h:385
TextState(const TextState &state)
Constructor, with another text state object.
Definition: fs_pdfgraphicsobject.h:815
Definition: fs_pdfpage.h:63
float GetCharHeightByIndex(int index) const
Get the height of a character specified by index in current text object.
void SetClipRect(const RectF &clip_rect)
Set clip rectangle.
Definition: fs_image.h:36
Definition: fs_pdfgraphicsobject.h:740
void SetFillColor(ARGB color)
Set the fill color.
bool GetStrokeState() const
Get stroke state.
Selecting source color and ignoring backdrop color.
Definition: fs_pdfgraphicsobject.h:167
Mode textmode
Text rendering mode. Please refer to values starting from TextState::e_ModeFill and this should be on...
Definition: fs_pdfgraphicsobject.h:925
void SetBlendMode(BlendMode blend_mode)
Set the blend mode for transparent imaging model.
CFX_Object Object
Object type.
Definition: fs_basictypes.h:219
Type
Enumeration for PDF graphics object type.
Definition: fs_pdfgraphicsobject.h:291
Color space: Lab.
Definition: fs_pdfgraphicsobject.h:971
uint32 version
Version of this class.
Definition: fs_pdfgraphicsobject.h:884
Multiply or screens colors, depending on backdrop color value.
Definition: fs_pdfgraphicsobject.h:185
BlendMode
Enumeration for render blend mode.
Definition: fs_pdfgraphicsobject.h:161
Form XObject graphics object.
Definition: fs_pdfgraphicsobject.h:303
int GetClipTextObjectCount() const
Get the count of text clip.
static FormXObject * Create(const PDFDoc &document)
Create a new form XObject graphics object.
Color space: ICCBased DeviceCMYK.
Definition: fs_pdfgraphicsobject.h:983
void SetGraphState(const common::GraphState &graph_state)
Set graph state.
Definition: fx_coordinates.h:30
TextState & operator=(const TextState &state)
Assign operator.
Definition: fs_pdfgraphicsobject.h:834
ARGB GetStrokeColor() const
Get the stroke color.
Header file for file operation related definitions and functions.
Color space: DeviceRGB.
Definition: fs_pdfgraphicsobject.h:963
Image graphics object.
Definition: fs_pdfgraphicsobject.h:299
static PathObject * CreateFromTextObject(const PDFPage &page, TextObject *text_obj)
Create a path graphics object from a text object.
LayerNodeArray GetLayers(const LayerTree &layer_tree)
Get all the layers which are associated with current graphics object.
Subtracts the darker of the two constituent colors from lighter colors.
Definition: fs_pdfgraphicsobject.h:248
common::FillMode GetFillMode() const
Get fill mode.
WIDE STRING CLASS.
Definition: fx_string.h:1452
Creates a color with the luminosity of the source color, and the hue and saturation of the backdrop c...
Definition: fs_pdfgraphicsobject.h:283
Definition: fs_pdflayer.h:38
Color space: CalGray.
Definition: fs_pdfgraphicsobject.h:967
CFX_ArrayTemplate< GraphicsObject * > GraphicsObjectArray
Definition: fs_pdfgraphicsobject.h:737
Darkens or lightens colors, depending on source color value.
Definition: fs_pdfgraphicsobject.h:242
int AddItem(const char *tag_name, objects::PDFDictionary *property_dict=0)
Add a new marked content item.
Definition: fs_pdfdoc.h:352
Color space: DeviceN.
Definition: fs_pdfgraphicsobject.h:975
Definition: fs_pdflayer.h:121
Text graphics object.
Definition: fs_pdfgraphicsobject.h:295
static PathObject * Create()
Create a new path graphics object.
GraphicsObject * Clone()
Clone a new graphics object.
bool RemoveClipPath(int index)
Remove a path clip by index.
Header file for image and bitmap related definitions and classes.
Darkens backdrop color to reflect the source color.
Definition: fs_pdfgraphicsobject.h:219
Represents all graphics object types, only used as filter.
Definition: fs_pdfgraphicsobject.h:293
void SetText(const wchar_t *text)
Set text string.
int GetItemMCID(int index) const
Get marked-content identifier (MCID) of a marked content item specified by index.
Text mode: fill and stroke text, and add to path for clipping.
Definition: fs_pdfgraphicsobject.h:761
void Set(uint32 version, const common::Font &font, float font_size, float charspace, float wordspace, Mode textmode, const PointF &origin_position, float textmatrix[4])
Set value.
Definition: fs_pdfgraphicsobject.h:863
common::Path GetPathData() const
Get the path data.
Color space: CalRGB.
Definition: fs_pdfgraphicsobject.h:969
Type GetType() const
Get the type of current graphics object.
Creates a color with the hue and saturation of the source color, and the luminosity of the backdrop c...
Definition: fs_pdfgraphicsobject.h:276
common::Bitmap CloneBitmap(const GraphicsObjects &graphics_objects)
Clone the bitmap from current image graphics object.
ColorSpace
Enumeration for image color space.
Definition: fs_pdfgraphicsobject.h:957
bool RemoveClipTextObject(int index)
Remove a text clip by index for clipping.
ARGB GetFillColor() const
Get the fill color.
void SetTextState(const PDFPage &page, const TextState &text_state, bool is_italic, int weight)
Set text state information.
ColorSpace GetColorSpace() const
Get color space.
TextObject * GetClipTextObject(int index) const
Get the text object of a text clip by index.
uint32 ARGB
ARGB color type, 32 bits, ((b) | ((g) << 8) | ((r) << 16)) | ((a) << 24)
Definition: fs_basictypes.h:212
void SetBitmap(const common::Bitmap &bitmap, const common::Bitmap &mask=common::Bitmap())
Set a bitmap to current image graphics object.
void SetStrokeState(bool is_stroke)
Set stroke state.
void SetMatrix(const Matrix &matrix)
Set matrix.
MarkedContent * GetMarkedContent() const
Get marked content object.
Definition: fs_pdfgraphicsobject.h:59
Brightens backdrop color to reflect source colors.
Definition: fs_pdfgraphicsobject.h:208
common::Font font
A font object.
Definition: fs_pdfgraphicsobject.h:890
void SetImage(const common::Image &image, int frame_index)
Set one frame of an image to current image graphics object.
objects::PDFStream * GetStream() const
Get image stream.
void SetPathData(const common::Path &path_data)
Set the path data.
Definition: fs_pdfgraphicsobject.h:1111
CFX_PointF PointF
Point information, in float.
Definition: fs_basictypes.h:413
Color space: Pattern.
Definition: fs_pdfgraphicsobject.h:977
void Rotate(int angle)
Rotate current graphics object from current state with specified angle degree in clockwise.
FillMode
Enumeration for filling mode type, mainly for path graphics object.
Definition: fs_common.h:307
Text mode: fill text.
Definition: fs_pdfgraphicsobject.h:749
common::Path GetClipPath(int index) const
Get a path clip by index.
float charspace
Character spacing.
Definition: fs_pdfgraphicsobject.h:905
static ImageObject * Create(const PDFDoc &document)
Create a new image graphics object.
bool HasTag(const char *tag_name)
Check whether current marked content object has a specified marked content item or not.
void SetStrokeColor(ARGB color)
Set the stroke color.
Definition: fs_common.h:893
Color space: ICCBased DeviceGray.
Definition: fs_pdfgraphicsobject.h:979
FormXObject * GetFormXObject() const
Get the form XObject graphics object if current graphics object represents a form XObject object.
Definition: fs_common.h:1879
bool RemoveItem(const char *tag_name)
Remove a marked content item by tag name.
RectF GetClipRect() const
Get clip rectangle.
ImageObject * GetImageObject() const
Get the image graphics object if current graphics object represents an image object.
Creates a color with the hue of the source color, and the saturation and luminosity of the backdrop c...
Definition: fs_pdfgraphicsobject.h:255
Definition: fs_pdfgraphicsobject.h:1331
Definition: fx_basic.h:1288
common::GraphState GetGraphState() const
Get graph state.
Color space: ICCBased DeviceRGB.
Definition: fs_pdfgraphicsobject.h:981
bool ClearClips()
Clear all clips.
Color space: Separation.
Definition: fs_pdfgraphicsobject.h:973
FX_UINT32 uint32
32-bit unsigned integer.
Definition: fs_basictypes.h:198
objects::PDFStream * GetStream() const
Get stream.
BlendMode GetBlendMode() const
Get the blend mode for transparent imaging model.
Definition: fs_pdfpage.h:313
Header file for common definitions and classes.
float GetFillOpacity() const
Get the opacity value for painting operations other than stroking.
~MarkedContent()
Destructor.
Definition: fs_pdfgraphicsobject.h:62
bool ImportPageContent(const PDFPage &source_page, bool is_annots_included)
Import page content from a specified PDF page to current form XObject.
void SetFillOpacity(float opacity)
Set the opacity value for painting operations other than stroking.
int GetItemCount() const
Get the count of marked content items.
bool AddClipTextObject(TextObject *textobject)
Add text object for clipping.
Path graphics object.
Definition: fs_pdfgraphicsobject.h:297
Header file for PDF object related definitions and classes.
Mode
Enumeration for text mode.
Definition: fs_pdfgraphicsobject.h:747
TextState GetTextState(const PDFPage &page) const
Get text state information.
void SetFillMode(common::FillMode fill_mode)
Set fill mode.
Definition: fs_pdfgraphicsobject.h:1396
TextObject * GetTextObject() const
Get the text graphics object if current graphics object represents a text object.
Multiply backdrop by source color values.
Definition: fs_pdfgraphicsobject.h:173
PointF origin_position
The origin point, in PDF coordinate system.
Definition: fs_pdfgraphicsobject.h:932
String GetItemTagName(int index) const
Get the tag name of a marked content item specified by index.
bool AddClipPath(const common::Path &path, common::FillMode fill_mode)
Add a path for clipping.
Text mode: add text to path for clipping.
Definition: fs_pdfgraphicsobject.h:763
Multiply complements of backdrop by source color values, and then complement the result.
Definition: fs_pdfgraphicsobject.h:179
Text mode: fill text and add to path for clipping.
Definition: fs_pdfgraphicsobject.h:757
Definition: fs_common.h:1315
Definition: fs_pdfobject.h:763
Select lighter one of backdrop and source colors.
Definition: fs_pdfgraphicsobject.h:197
Foxit namespace.
Definition: fs_compare.h:27
PointF GetCharPos(int index) const
Get the position of a character specified by index in current text object.
Definition: fs_pdfobject.h:55
Text mode: stroke text.
Definition: fs_pdfgraphicsobject.h:751
BYTE STRING CLASS.
Definition: fx_string.h:317
void SetStrokeOpacity(float opacity)
Set opacity value for stroke painting operations for paths and glyph outlines.
Text mode: stroke text and add to path for clipping.
Definition: fs_pdfgraphicsobject.h:759
WString GetText() const
Get text string.
float textmatrix[4]
Text transformation matrix.
Definition: fs_pdfgraphicsobject.h:939
Text mode: fill and stroke text.
Definition: fs_pdfgraphicsobject.h:753
Color space: DeviceCMYK.
Definition: fs_pdfgraphicsobject.h:965
GraphicsObjects GetGraphicsObjects() const
Get graphics objects that associated with current form XObject.
Matrix GetMatrix() const
Get matrix.
void Release()
Release a cloned or newly created PDF graphics object which has not been inserted into any PDF page o...
Definition: fs_pdfgraphicsobject.h:1227
#define NULL
The null-pointer value.
Definition: fx_system.h:767
Definition: fx_coordinates.h:1074
static TextObject * Create()
Create a new text graphics object.
Multiply or screens colors, depending on source color value.
Definition: fs_pdfgraphicsobject.h:229
objects::PDFObject * GetPDFObject() const
Get the PDF object which represents the shading graphics object in PDF file.
PathObject * GetPathObject() const
Get the path graphics object if current graphics object represents a path object.
float GetStrokeOpacity() const
Get opacity value for stroke painting operations for paths and glyph outlines.
objects::PDFDictionary * GetItemPropertyDict(int index) const
Get the property dictionary of a marked content item specified by index.
float font_size
Font size. If valid, it should be above 0.
Definition: fs_pdfgraphicsobject.h:896
int GetCharCount() const
Get character count in current text object.
Creates a color with the hue of the source color, and the saturation and luminosity of the backdrop c...
Definition: fs_pdfgraphicsobject.h:262
TextState()
Constructor.
Definition: fs_pdfgraphicsobject.h:797
bool IsImageMask() const
Check if current image object is treated as mask.
objects::PDFObject * GetMask() const
Get the PDF object that represents the mask of current image graphics object.
Select darker one of backdrop and source colors.
Definition: fs_pdfgraphicsobject.h:191
Shading graphics object.
Definition: fs_pdfgraphicsobject.h:301
Definition: fs_image.h:430
float GetCharWidthByIndex(int index) const
Get the width of a character specified by index in current text object.
Definition: fs_pdfgraphicsobject.h:950
RectF GetRect() const
Get the rectangle of current graphics object.
Creates a color with the saturation of the source color, and the hue and luminosity of the backdrop c...
Definition: fs_pdfgraphicsobject.h:269
bool Transform(const Matrix &matrix, bool need_transform_clippath)
Transform current graphics object.
Color space: DeviceGray.
Definition: fs_pdfgraphicsobject.h:961
Definition: fx_coordinates.h:769
Text mode: neither fill nor stroke text, to make it invisible.
Definition: fs_pdfgraphicsobject.h:755