My Project
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 
390  void SetFillColor(ARGB color);
391 
398  Matrix GetMatrix() const;
399 
410  void SetMatrix(const Matrix& matrix);
411 
424  bool Transform(const Matrix& matrix, bool need_transform_clippath);
425 
437 
446 
461  void SetGraphState(const common::GraphState& graph_state);
462 
469  BlendMode GetBlendMode() const;
470 
482  void SetBlendMode(BlendMode blend_mode);
483 
489  int GetClipPathCount() const;
490 
500  common::Path GetClipPath(int index) const;
501 
511  common::FillMode GetClipPathFillMode(int index) const;
512 
525  bool AddClipPath(const common::Path& path, common::FillMode fill_mode);
526 
538  bool RemoveClipPath(int index);
539 
545  int GetClipTextObjectCount() const;
546 
555  TextObject* GetClipTextObject(int index) const;
556 
567  bool AddClipTextObject(TextObject* textobject);
568 
580  bool RemoveClipTextObject(int index);
581 
587  RectF GetClipRect() const;
588 
601  void SetClipRect(const RectF& clip_rect);
602 
611  bool ClearClips();
612 
619 
628  LayerNodeArray GetLayers(const LayerTree& layer_tree);
629 
636  TextObject* GetTextObject() const;
637 
644  FormXObject* GetFormXObject() const;
645 
652  ImageObject* GetImageObject() const;
653 
660  PathObject* GetPathObject() const;
668 
669  protected:
670  ~GraphicsObject() {}
671 
672  private:
673  GraphicsObject(const GraphicsObject& graphicsobject);
674  GraphicsObject &operator = (const GraphicsObject& graphicsobject);
675 };
676 
679 
681 class TextState FS_FINAL : public Object {
682  public:
688  typedef enum _Mode {
705  } Mode;
706 
707 
725  const PointF& origin_position, float textmatrix[4]) {
726  this->version = version;
727  this->font = font;
728  this->font_size = font_size;
729  this->charspace = charspace;
730  this->wordspace = wordspace;
731  this->textmode = textmode;
732  this->origin_position = origin_position;
733  for (int i=0; i < 4; i++)
734  this->textmatrix[i] = textmatrix[i];
735  }
736 
739  :version(1)
740  , font_size(0)
741  , charspace(0)
742  , wordspace(0)
745  this->textmatrix[0] = 1;
746  this->textmatrix[1] = 0;
747  this->textmatrix[2] = 0;
748  this->textmatrix[3] = 1;
749  }
750 
756  TextState(const TextState& state) {
757  version = state.version;
758  font = state.font;
759  font_size = state.font_size;
760  charspace = state.charspace;
761  wordspace = state.wordspace;
762  textmode = state.textmode;
764  for (int i=0; i < 4; i++)
765  textmatrix[i] = state.textmatrix[i];
766  }
767 
775  TextState &operator = (const TextState& state) {
776  version = state.version;
777  font = state.font;
778  font_size = state.font_size;
779  charspace = state.charspace;
780  wordspace = state.wordspace;
781  textmode = state.textmode;
783  for (int i=0; i < 4; i++)
784  textmatrix[i] = state.textmatrix[i];
785  return (*this);
786  }
787 
804  void Set(uint32 version, const common::Font& font, float font_size, float charspace, float wordspace,
805  Mode textmode, const PointF& origin_position, float textmatrix[4]) {
806  this->version = version;
807  this->font = font;
808  this->font_size = font_size;
809  this->charspace = charspace;
810  this->wordspace = wordspace;
811  this->textmode = textmode;
812  this->origin_position = origin_position;
813  for (int i=0; i < 4; i++)
814  this->textmatrix[i] = textmatrix[i];
815  }
816 
835  float font_size;
844  float charspace;
855  float wordspace;
871  float textmatrix[4];
872 };
873 
882 class ImageObject FS_FINAL : public GraphicsObject {
883  public:
889  typedef enum _ColorSpace {
916  } ColorSpace;
917 
918 
932  static ImageObject* Create(const PDFDoc& document);
933 
948  void SetBitmap(const common::Bitmap& bitmap, const common::Bitmap& mask = common::Bitmap());
949 
967  void SetImage(const common::Image& image, int frame_index);
968 
986  common::Bitmap CloneBitmap(const GraphicsObjects& graphics_objects);
987 
994  ColorSpace GetColorSpace() const;
995 
1002  objects::PDFStream* GetStream() const;
1003 
1009  bool IsImageMask() const;
1010 
1024  objects::PDFObject* GetMask() const;
1025 
1026  private:
1027  ImageObject(const ImageObject& imageobject);
1028  ImageObject &operator = (const ImageObject& imageobject);
1029 
1030  ~ImageObject() {}
1031 };
1032 
1041 class TextObject FS_FINAL : public GraphicsObject {
1042  public:
1053  static TextObject* Create();
1054 
1060  WString GetText() const;
1074  void SetText(const wchar_t* text);
1082  TextState GetTextState(const PDFPage& page) const;
1097  void SetTextState(const PDFPage& page, const TextState& text_state, bool is_italic, int weight);
1098 
1099  private:
1100  TextObject(const TextObject& textobject);
1101  TextObject &operator = (const TextObject& textobject);
1102 
1103  ~TextObject() {}
1104 };
1105 
1116 class PathObject FS_FINAL : public GraphicsObject {
1117  public:
1128  static PathObject* Create();
1129 
1141  static PathObject* CreateFromTextObject(const PDFPage& page, TextObject* text_obj);
1142 
1149  common::FillMode GetFillMode() const;
1161  void SetFillMode(common::FillMode fill_mode);
1168  bool GetStrokeState() const;
1180  void SetStrokeState(bool is_stroke);
1187  common::Path GetPathData() const;
1188 
1199  void SetPathData(const common::Path& path_data);
1200 
1201  private:
1202  PathObject(const PathObject& pathobject);
1203  PathObject &operator = (const PathObject& pathobject);
1204 
1205  ~PathObject() {}
1206 };
1207 
1219 class FormXObject FS_FINAL : public GraphicsObject {
1220  public:
1234  static FormXObject* Create(const PDFDoc& document);
1235 
1242  objects::PDFStream* GetStream() const;
1243 
1267  bool ImportPageContent(const PDFPage& source_page, bool is_annots_included);
1268 
1269  private:
1270  FormXObject(const FormXObject& formxobject);
1271  FormXObject &operator = (const FormXObject& formxobject);
1272 
1273  ~FormXObject() {}
1274 };
1275 
1282 class ShadingObject FS_FINAL : public GraphicsObject {
1283  public:
1291 
1292  private:
1293  ShadingObject(const ShadingObject& shadingobject);
1294  ShadingObject &operator = (const ShadingObject& shadingobject);
1295 
1296  ~ShadingObject() {}
1297 };
1298 } // namespace graphics
1299 } // namespace pdf
1300 } // namespace foxit
1301 #endif // FS_PDFGRAPHICSOBJECT_H_
1302 
Color space: Invalid.
Definition: fs_pdfgraphicsobject.h:891
Definition: fs_pdfgraphicsobject.h:59
Definition: fs_pdfgraphicsobject.h:1219
float textmatrix[4]
Text transformation matrix.
Definition: fs_pdfgraphicsobject.h:871
Color space: CalGray.
Definition: fs_pdfgraphicsobject.h:899
Definition: fs_pdflayer.h:38
void Release()
Release a cloned or newly created PDF graphics object which has not been inserted into any PDF page o...
int GetItemCount() const
Get the count of marked content items.
bool RemoveClipTextObject(int index)
Remove a text clip by index for clipping.
RectF GetClipRect() const
Get clip rectangle.
TextObject * GetTextObject() const
Get the text graphics object if current graphics object represents a text 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:724
bool HasTag(const char *tag_name)
Check whether current marked content object has a specified marked content item or not.
Darkens backdrop color to reflect the source color.
Definition: fs_pdfgraphicsobject.h:219
Select darker one of backdrop and source colors.
Definition: fs_pdfgraphicsobject.h:191
Color space: DeviceCMYK.
Definition: fs_pdfgraphicsobject.h:897
objects::PDFDictionary * GetItemPropertyDict(int index) const
Get the property dictionary of a marked content item specified by index.
WString GetText() const
Get text string.
int GetClipPathCount() const
Get the count of path clip.
bool RemoveItem(const char *tag_name)
Remove a marked content item by tag name.
Creates a color with the hue of the source color, and the saturation and luminosity of the backdrop c...
Definition: fs_pdfgraphicsobject.h:262
void SetFillMode(common::FillMode fill_mode)
Set fill mode.
static FormXObject * Create(const PDFDoc &document)
Create a new form XObject graphics object.
Darkens or lightens colors, depending on source color value.
Definition: fs_pdfgraphicsobject.h:242
Shading graphics object.
Definition: fs_pdfgraphicsobject.h:301
CFX_Object Object
Object type.
Definition: fs_basictypes.h:219
Definition: fs_common.h:769
Mode textmode
Text rendering mode. Please refer to values starting from TextState::e_ModeFill and this should be on...
Definition: fs_pdfgraphicsobject.h:861
ImageObject * GetImageObject() const
Get the image graphics object if current graphics object represents an image object.
bool HasTransparency()
Check whether current graphics object has transparency or not.
static PathObject * Create()
Create a new path graphics object.
Type
Enumeration for PDF graphics object type.
Definition: fs_pdfgraphicsobject.h:291
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:804
TextState(const TextState &state)
Constructor, with another text state object.
Definition: fs_pdfgraphicsobject.h:756
Color space: DeviceN.
Definition: fs_pdfgraphicsobject.h:907
float charspace
Character spacing.
Definition: fs_pdfgraphicsobject.h:844
PointF origin_position
The origin point, in PDF coordinate system.
Definition: fs_pdfgraphicsobject.h:866
Color space: ICCBased DeviceGray.
Definition: fs_pdfgraphicsobject.h:911
Header file for common definitions and classes.
Definition: fs_pdfgraphicsobject.h:1116
Definition: fx_basic.h:1287
static TextObject * Create()
Create a new text graphics object.
common::Path GetClipPath(int index) const
Get a path clip by index.
bool GetStrokeState() const
Get stroke state.
Text mode: fill and stroke text.
Definition: fs_pdfgraphicsobject.h:694
TextState & operator=(const TextState &state)
Assign operator.
Definition: fs_pdfgraphicsobject.h:775
Header file for file operation related definitions and functions.
~MarkedContent()
Destructor.
Definition: fs_pdfgraphicsobject.h:62
uint32 ARGB
ARGB color type, 32 bits, ((b) | ((g) << 8) | ((r) << 16)) | ((a) << 24)
Definition: fs_basictypes.h:212
Definition: fs_pdfgraphicsobject.h:1282
Brightens backdrop color to reflect source colors.
Definition: fs_pdfgraphicsobject.h:208
Text mode: add text to path for clipping.
Definition: fs_pdfgraphicsobject.h:704
Definition: fs_pdfobject.h:55
common::Bitmap CloneBitmap(const GraphicsObjects &graphics_objects)
Clone the bitmap from current image graphics object.
Selecting source color and ignoring backdrop color.
Definition: fs_pdfgraphicsobject.h:167
void SetImage(const common::Image &image, int frame_index)
Set one frame of an image to current image graphics object.
bool Transform(const Matrix &matrix, bool need_transform_clippath)
Transform current graphics object.
Definition: fs_common.h:1467
BlendMode GetBlendMode() const
Get the blend mode for transparent imaging model.
void SetClipRect(const RectF &clip_rect)
Set clip rectangle.
Multiply or screens colors, depending on backdrop color value.
Definition: fs_pdfgraphicsobject.h:185
Definition: fs_pdflayer.h:121
RectF GetRect() const
Get the rectangle of current graphics object.
Form XObject graphics object.
Definition: fs_pdfgraphicsobject.h:303
Color space: Pattern.
Definition: fs_pdfgraphicsobject.h:909
FormXObject * GetFormXObject() const
Get the form XObject graphics object if current graphics object represents a form XObject object.
Text mode: stroke text.
Definition: fs_pdfgraphicsobject.h:692
objects::PDFStream * GetStream() const
Get image stream.
Color space: ICCBased DeviceRGB.
Definition: fs_pdfgraphicsobject.h:913
Color space: ICCBased DeviceCMYK.
Definition: fs_pdfgraphicsobject.h:915
void SetStrokeColor(ARGB color)
Set the stroke color.
Matrix GetMatrix() const
Get matrix.
Image graphics object.
Definition: fs_pdfgraphicsobject.h:299
Subtracts the darker of the two constituent colors from lighter colors.
Definition: fs_pdfgraphicsobject.h:248
BYTE STRING CLASS.
Definition: fx_string.h:317
ColorSpace
Enumeration for image color space.
Definition: fs_pdfgraphicsobject.h:889
static ImageObject * Create(const PDFDoc &document)
Create a new image graphics object.
Multiply backdrop by source color values.
Definition: fs_pdfgraphicsobject.h:173
Creates a color with the luminosity of the source color, and the hue and saturation of the backdrop c...
Definition: fs_pdfgraphicsobject.h:283
Text mode: fill text.
Definition: fs_pdfgraphicsobject.h:690
Definition: fx_coordinates.h:30
Text mode: neither fill nor stroke text, to make it invisible.
Definition: fs_pdfgraphicsobject.h:696
void SetBitmap(const common::Bitmap &bitmap, const common::Bitmap &mask=common::Bitmap())
Set a bitmap to current image graphics object.
Multiply complements of backdrop by source color values, and then complement the result.
Definition: fs_pdfgraphicsobject.h:179
TextState GetTextState(const PDFPage &page) const
Get text state information.
Mode
Enumeration for text mode.
Definition: fs_pdfgraphicsobject.h:688
Definition: fs_pdfgraphicsobject.h:1041
Definition: fs_pdfgraphicsobject.h:154
Text graphics object.
Definition: fs_pdfgraphicsobject.h:295
Creates a color with the hue and saturation of the source color, and the luminosity of the backdrop c...
Definition: fs_pdfgraphicsobject.h:276
Color space: DeviceRGB.
Definition: fs_pdfgraphicsobject.h:895
void SetFillColor(ARGB color)
Set the fill color.
FillMode
Enumeration for filling mode type, mainly for path graphics object.
Definition: fs_common.h:253
Header file for PDF object related definitions and classes.
ColorSpace GetColorSpace() const
Get color space.
bool RemoveClipPath(int index)
Remove a path clip by index.
bool AddClipPath(const common::Path &path, common::FillMode fill_mode)
Add a path for clipping.
Represents all graphics object types, only used as filter.
Definition: fs_pdfgraphicsobject.h:293
Foxit namespace.
Definition: fs_connectedpdf.h:26
TextState()
Constructor.
Definition: fs_pdfgraphicsobject.h:738
int GetClipTextObjectCount() const
Get the count of text clip.
CFX_ArrayTemplate< GraphicsObject * > GraphicsObjectArray
Definition: fs_pdfgraphicsobject.h:678
void SetStrokeState(bool is_stroke)
Set stroke state.
Type GetType() const
Get the type of current graphics object.
bool ImportPageContent(const PDFPage &source_page, bool is_annots_included)
Import page content from a specified PDF page to current form XObject.
common::Font font
A font object.
Definition: fs_pdfgraphicsobject.h:830
common::Path GetPathData() const
Get the path data.
Multiply or screens colors, depending on source color value.
Definition: fs_pdfgraphicsobject.h:229
Header file for image and bitmap related definitions and classes.
Definition: fs_pdfobject.h:763
PathObject * GetPathObject() const
Get the path graphics object if current graphics object represents a path object.
ARGB GetStrokeColor() const
Get the stroke color.
int AddItem(const char *tag_name, objects::PDFDictionary *property_dict=0)
Add a new marked content item.
LayerNodeArray GetLayers(const LayerTree &layer_tree)
Get all the layers which are associated with current graphics object.
bool AddClipTextObject(TextObject *textobject)
Add text object for clipping.
void SetMatrix(const Matrix &matrix)
Set matrix.
MarkedContent * GetMarkedContent() const
Get marked content object.
Definition: fs_pdfgraphicsobject.h:882
#define NULL
The null-pointer value.
Definition: fx_system.h:773
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: fx_coordinates.h:763
int GetItemMCID(int index) const
Get marked-content identifier (MCID) of a marked content item specified by index.
String GetItemTagName(int index) const
Get the tag name of a marked content item specified by index.
Creates a color with the saturation of the source color, and the hue and luminosity of the backdrop c...
Definition: fs_pdfgraphicsobject.h:269
Definition: fs_pdfdoc.h:338
Definition: fs_pdfpage.h:307
Text mode: fill text and add to path for clipping.
Definition: fs_pdfgraphicsobject.h:698
Text mode: fill and stroke text, and add to path for clipping.
Definition: fs_pdfgraphicsobject.h:702
float font_size
Font size. If valid, it should be above 0.
Definition: fs_pdfgraphicsobject.h:835
static PathObject * CreateFromTextObject(const PDFPage &page, TextObject *text_obj)
Create a path graphics object from a text object.
Definition: fs_image.h:426
common::FillMode GetClipPathFillMode(int index) const
Get the fill mode of a path clip by index.
common::GraphState GetGraphState() const
Get graph state.
Color space: Separation.
Definition: fs_pdfgraphicsobject.h:905
float wordspace
Word spacing (only apply to space character).
Definition: fs_pdfgraphicsobject.h:855
GraphicsObjects GetGraphicsObjects() const
Get graphics objects that associated with current form XObject.
CFX_PointF PointF
Point information, in float.
Definition: fs_basictypes.h:362
uint32 version
Version of this class.
Definition: fs_pdfgraphicsobject.h:825
Text mode: stroke text and add to path for clipping.
Definition: fs_pdfgraphicsobject.h:700
Definition: fs_common.h:1188
Definition: fx_coordinates.h:1053
objects::PDFObject * GetPDFObject() const
Get the PDF object which represents the shading graphics object in PDF file.
ShadingObject * GetShadingObject() const
Get the shading graphics object if current graphics object represents a shading object.
common::FillMode GetFillMode() const
Get fill mode.
void SetGraphState(const common::GraphState &graph_state)
Set graph state.
bool ClearClips()
Clear all clips.
void SetText(const wchar_t *text)
Set text string.
Definition: fs_pdfobject.h:385
void SetTextState(const PDFPage &page, const TextState &text_state, bool is_italic, int weight)
Set text state information.
WIDE STRING CLASS.
Definition: fx_string.h:1470
Definition: fs_image.h:36
void SetPathData(const common::Path &path_data)
Set the path data.
Color space: CalRGB.
Definition: fs_pdfgraphicsobject.h:901
Definition: fs_pdfgraphicsobject.h:681
Path graphics object.
Definition: fs_pdfgraphicsobject.h:297
objects::PDFStream * GetStream() const
Get stream.
Color space: DeviceGray.
Definition: fs_pdfgraphicsobject.h:893
FX_UINT32 uint32
32-bit unsigned integer.
Definition: fs_basictypes.h:198
Select lighter one of backdrop and source colors.
Definition: fs_pdfgraphicsobject.h:197
void SetBlendMode(BlendMode blend_mode)
Set the blend mode for transparent imaging model.
ARGB GetFillColor() const
Get the fill color.
Color space: Lab.
Definition: fs_pdfgraphicsobject.h:903
BlendMode
Enumeration for render blend mode.
Definition: fs_pdfgraphicsobject.h:161
GraphicsObject * Clone()
Clone a new graphics object.
objects::PDFObject * GetMask() const
Get the PDF object that represents the mask of current image graphics object.
Definition: fs_pdfpage.h:59
bool IsImageMask() const
Check if current image object is treated as mask.
TextObject * GetClipTextObject(int index) const
Get the text object of a text clip by index.

Foxit Software Corporation Logo
@2019 Foxit Software Incorporated. All rights reserved.