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 
153 class GraphicsObject : public Object {
154  public:
160  typedef enum _BlendMode {
291  } BlendMode;
292 
298  typedef enum _Type {
311  } Type;
312 
313 
314 #if !defined(_SWIG_IOS_) && !defined(_SWIG_MACOC_)
315 
321  void Release();
322 #endif
323 
330  Type GetType() const;
331 
338  RectF GetRect() const;
339 
345  bool HasTransparency();
346 
354  ARGB GetStrokeColor() const;
355 
363  ARGB GetFillColor() const;
364 
382  void SetStrokeColor(ARGB color);
383 
398  void SetFillColor(ARGB color);
399 
406  Matrix GetMatrix() const;
407 
418  void SetMatrix(const Matrix& matrix);
419 
432  bool Transform(const Matrix& matrix, bool need_transform_clippath);
433 
445 
454 
469  void SetGraphState(const common::GraphState& graph_state);
470 
477  BlendMode GetBlendMode() const;
478 
490  void SetBlendMode(BlendMode blend_mode);
491 
497  int GetClipPathCount() const;
498 
508  common::Path GetClipPath(int index) const;
509 
519  common::FillMode GetClipPathFillMode(int index) const;
520 
533  bool AddClipPath(const common::Path& path, common::FillMode fill_mode);
534 
546  bool RemoveClipPath(int index);
547 
553  int GetClipTextObjectCount() const;
554 
563  TextObject* GetClipTextObject(int index) const;
564 
575  bool AddClipTextObject(TextObject* textobject);
576 
588  bool RemoveClipTextObject(int index);
589 
595  RectF GetClipRect() const;
596 
609  void SetClipRect(const RectF& clip_rect);
610 
619  bool ClearClips();
620 
627 
636  LayerNodeArray GetLayers(const LayerTree& layer_tree);
637 
644  TextObject* GetTextObject() const;
645 
652  FormXObject* GetFormXObject() const;
653 
660  ImageObject* GetImageObject() const;
661 
668  PathObject* GetPathObject() const;
676 
677  protected:
678  ~GraphicsObject() {}
679 
680  private:
681  GraphicsObject(const GraphicsObject& graphicsobject);
682  GraphicsObject &operator = (const GraphicsObject& graphicsobject);
683 };
684 
687 
689 class TextState FS_FINAL : public Object {
690  public:
696  typedef enum _Mode {
713  } Mode;
714 
715 
733  const PointF& origin_position, float textmatrix[4]) {
734  this->version = version;
735  this->font = font;
736  this->font_size = font_size;
737  this->charspace = charspace;
738  this->wordspace = wordspace;
739  this->textmode = textmode;
740  this->origin_position = origin_position;
741  for (int i=0; i < 4; i++)
742  this->textmatrix[i] = textmatrix[i];
743  }
744 
747  :version(1)
748  , font_size(0)
749  , charspace(0)
750  , wordspace(0)
753  this->textmatrix[0] = 1;
754  this->textmatrix[1] = 0;
755  this->textmatrix[2] = 0;
756  this->textmatrix[3] = 1;
757  }
758 
764  TextState(const TextState& state) {
765  version = state.version;
766  font = state.font;
767  font_size = state.font_size;
768  charspace = state.charspace;
769  wordspace = state.wordspace;
770  textmode = state.textmode;
772  for (int i=0; i < 4; i++)
773  textmatrix[i] = state.textmatrix[i];
774  }
775 
783  TextState &operator = (const TextState& state) {
784  version = state.version;
785  font = state.font;
786  font_size = state.font_size;
787  charspace = state.charspace;
788  wordspace = state.wordspace;
789  textmode = state.textmode;
791  for (int i=0; i < 4; i++)
792  textmatrix[i] = state.textmatrix[i];
793  return (*this);
794  }
795 
812  void Set(uint32 version, const common::Font& font, float font_size, float charspace, float wordspace,
813  Mode textmode, const PointF& origin_position, float textmatrix[4]) {
814  this->version = version;
815  this->font = font;
816  this->font_size = font_size;
817  this->charspace = charspace;
818  this->wordspace = wordspace;
819  this->textmode = textmode;
820  this->origin_position = origin_position;
821  for (int i=0; i < 4; i++)
822  this->textmatrix[i] = textmatrix[i];
823  }
824 
843  float font_size;
852  float charspace;
863  float wordspace;
879  float textmatrix[4];
880 };
881 
890 class ImageObject FS_FINAL : public GraphicsObject {
891  public:
897  typedef enum _ColorSpace {
924  } ColorSpace;
925 
926 
940  static ImageObject* Create(const PDFDoc& document);
941 
956  void SetBitmap(const common::Bitmap& bitmap, const common::Bitmap& mask = common::Bitmap());
957 
975  void SetImage(const common::Image& image, int frame_index);
976 
994  common::Bitmap CloneBitmap(const GraphicsObjects& graphics_objects);
995 
1002  ColorSpace GetColorSpace() const;
1003 
1010  objects::PDFStream* GetStream() const;
1011 
1017  bool IsImageMask() const;
1018 
1032  objects::PDFObject* GetMask() const;
1033 
1034  private:
1035  ImageObject(const ImageObject& imageobject);
1036  ImageObject &operator = (const ImageObject& imageobject);
1037 
1038  ~ImageObject() {}
1039 };
1040 
1049 class TextObject FS_FINAL : public GraphicsObject {
1050  public:
1061  static TextObject* Create();
1062 
1068  WString GetText() const;
1082  void SetText(const wchar_t* text);
1090  TextState GetTextState(const PDFPage& page) const;
1105  void SetTextState(const PDFPage& page, const TextState& text_state, bool is_italic, int weight);
1106 
1107  private:
1108  TextObject(const TextObject& textobject);
1109  TextObject &operator = (const TextObject& textobject);
1110 
1111  ~TextObject() {}
1112 };
1113 
1124 class PathObject FS_FINAL : public GraphicsObject {
1125  public:
1136  static PathObject* Create();
1137 
1149  static PathObject* CreateFromTextObject(const PDFPage& page, TextObject* text_obj);
1150 
1157  common::FillMode GetFillMode() const;
1169  void SetFillMode(common::FillMode fill_mode);
1176  bool GetStrokeState() const;
1188  void SetStrokeState(bool is_stroke);
1195  common::Path GetPathData() const;
1196 
1207  void SetPathData(const common::Path& path_data);
1208 
1209  private:
1210  PathObject(const PathObject& pathobject);
1211  PathObject &operator = (const PathObject& pathobject);
1212 
1213  ~PathObject() {}
1214 };
1215 
1227 class FormXObject FS_FINAL : public GraphicsObject {
1228  public:
1242  static FormXObject* Create(const PDFDoc& document);
1243 
1250  objects::PDFStream* GetStream() const;
1251 
1275  bool ImportPageContent(const PDFPage& source_page, bool is_annots_included);
1276 
1277  private:
1278  FormXObject(const FormXObject& formxobject);
1279  FormXObject &operator = (const FormXObject& formxobject);
1280 
1281  ~FormXObject() {}
1282 };
1283 
1290 class ShadingObject FS_FINAL : public GraphicsObject {
1291  public:
1299 
1300  private:
1301  ShadingObject(const ShadingObject& shadingobject);
1302  ShadingObject &operator = (const ShadingObject& shadingobject);
1303 
1304  ~ShadingObject() {}
1305 };
1306 } // namespace graphics
1307 } // namespace pdf
1308 } // namespace foxit
1309 #endif // FS_PDFGRAPHICSOBJECT_H_
1310 
Definition: fs_pdfgraphicsobject.h:153
common::FillMode GetClipPathFillMode(int index) const
Get the fill mode of a path clip by index.
ShadingObject * GetShadingObject() const
Get the shading 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:732
float wordspace
Word spacing (only apply to space character).
Definition: fs_pdfgraphicsobject.h:863
int GetClipPathCount() const
Get the count of path clip.
Color space: Invalid.
Definition: fs_pdfgraphicsobject.h:899
bool HasTransparency()
Check whether current graphics object has transparency or not.
Definition: fs_pdfobject.h:385
TextState(const TextState &state)
Constructor, with another TextState object.
Definition: fs_pdfgraphicsobject.h:764
Definition: fs_pdfpage.h:59
void SetClipRect(const RectF &clip_rect)
Set clip rectangle.
Definition: fs_image.h:36
Definition: fs_pdfgraphicsobject.h:689
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:869
void SetBlendMode(BlendMode blend_mode)
Set the blend mode for transparent imaging model.
CFX_Object Object
Object type.
Definition: fs_basictypes.h:216
Type
Enumeration for PDF graphics object type.
Definition: fs_pdfgraphicsobject.h:298
Color space: Lab.
Definition: fs_pdfgraphicsobject.h:911
uint32 version
Version of this class.
Definition: fs_pdfgraphicsobject.h:833
Multiply or screens colors, depending on backdrop color value.
Definition: fs_pdfgraphicsobject.h:188
BlendMode
Enumeration for render blend mode.
Definition: fs_pdfgraphicsobject.h:160
Form XObject graphics object.
Definition: fs_pdfgraphicsobject.h:310
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:923
void SetGraphState(const common::GraphState &graph_state)
Set graph state.
TextState & operator=(const TextState &state)
Assign operator.
Definition: fs_pdfgraphicsobject.h:783
ARGB GetStrokeColor() const
Get the stroke color.
Header file for file operation related definitions and functions.
Color space: DeviceRGB.
Definition: fs_pdfgraphicsobject.h:903
Image graphics object.
Definition: fs_pdfgraphicsobject.h:306
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:250
common::FillMode GetFillMode() const
Get fill mode.
WIDE STRING CLASS.
Definition: fx_string.h:1463
Creates a color with the luminosity of the source color, and the hue and saturation of the backdrop c...
Definition: fs_pdfgraphicsobject.h:290
Definition: fs_pdflayer.h:38
Color space: CalGray.
Definition: fs_pdfgraphicsobject.h:907
CFX_ArrayTemplate< GraphicsObject * > GraphicsObjectArray
Definition: fs_pdfgraphicsobject.h:686
Darkens or lightens colors, depending on source color value.
Definition: fs_pdfgraphicsobject.h:243
int AddItem(const char *tag_name, objects::PDFDictionary *property_dict=0)
Add a new marked content item.
Definition: fs_pdfdoc.h:338
Color space: DeviceN.
Definition: fs_pdfgraphicsobject.h:915
Definition: fs_pdflayer.h:121
Text graphics object.
Definition: fs_pdfgraphicsobject.h:302
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:222
Represents all graphics object types, only used as filter.
Definition: fs_pdfgraphicsobject.h:300
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:710
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:812
common::Path GetPathData() const
Get the path data.
Color space: CalRGB.
Definition: fs_pdfgraphicsobject.h:909
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:282
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:897
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:209
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:212
common::Font font
Font object.
Definition: fs_pdfgraphicsobject.h:838
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:1049
CFX_PointF PointF
Point information, in float.
Definition: fs_basictypes.h:353
Color space: Pattern.
Definition: fs_pdfgraphicsobject.h:917
FillMode
Enumeration for filling mode type, mainly for path graphics object.
Definition: fs_common.h:251
Text mode: fill text.
Definition: fs_pdfgraphicsobject.h:698
common::Path GetClipPath(int index) const
Get a path clip by index.
float charspace
Character spacing.
Definition: fs_pdfgraphicsobject.h:852
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:759
Color space: ICCBased DeviceGray.
Definition: fs_pdfgraphicsobject.h:919
FormXObject * GetFormXObject() const
Get the form XObject object if current graphics object represents a form XObject object.
Definition: fs_common.h:1453
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 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:258
Definition: fs_pdfgraphicsobject.h:1227
Definition: fx_basic.h:1246
common::GraphState GetGraphState() const
Get graph state.
Color space: ICCBased DeviceRGB.
Definition: fs_pdfgraphicsobject.h:921
bool ClearClips()
Clear all clips.
Color space: Separation.
Definition: fs_pdfgraphicsobject.h:913
FX_UINT32 uint32
32-bit unsigned integer.
Definition: fs_basictypes.h:195
objects::PDFStream * GetStream() const
Get stream.
BlendMode GetBlendMode() const
Get the blend mode for transparent imaging model.
Definition: fs_pdfpage.h:306
Header file for common definitions and classes.
~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.
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:304
Header file for PDF object related definitions and classes.
Mode
Enumeration for text mode.
Definition: fs_pdfgraphicsobject.h:696
TextState GetTextState(const PDFPage &page) const
Get text state information.
void SetFillMode(common::FillMode fill_mode)
Set fill mode.
Definition: fs_pdfgraphicsobject.h:1290
TextObject * GetTextObject() const
Get the text object if current graphics object represents a text object.
Multiply backdrop by source color values.
Definition: fs_pdfgraphicsobject.h:174
PointF origin_position
The origin point, in PDF coordinate system.
Definition: fs_pdfgraphicsobject.h:874
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:712
Multiply complements of backdrop by source color values, and then complement the result.
Definition: fs_pdfgraphicsobject.h:181
Text mode: fill text and add to path for clipping.
Definition: fs_pdfgraphicsobject.h:706
Definition: fs_common.h:1176
Definition: fs_pdfobject.h:762
Select lighter one of backdrop and source colors.
Definition: fs_pdfgraphicsobject.h:202
Foxit namespace.
Definition: fs_connectedpdf.h:26
Definition: fs_pdfobject.h:55
Text mode: stroke text.
Definition: fs_pdfgraphicsobject.h:700
BYTE STRING CLASS.
Definition: fx_string.h:317
Text mode: stroke text and add to path for clipping.
Definition: fs_pdfgraphicsobject.h:708
WString GetText() const
Get text string.
float textmatrix[4]
Text transformation matrix.
Definition: fs_pdfgraphicsobject.h:879
Text mode: fill and stroke text.
Definition: fs_pdfgraphicsobject.h:702
Color space: DeviceCMYK.
Definition: fs_pdfgraphicsobject.h:905
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:1124
#define NULL
The null-pointer value.
Definition: fx_system.h:767
Definition: fx_coordinates.h:914
static TextObject * Create()
Create a new text graphics object.
Multiply or screens colors, depending on source color value.
Definition: fs_pdfgraphicsobject.h:231
objects::PDFObject * GetPDFObject() const
Get the PDF object which represents the shading graphics object in PDF file.
PathObject * GetPathObject() const
Get the path object if current graphics object represents a path object.
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:843
Creates a color with the hue of the source color, and the saturation and luminosity of the backdrop c...
Definition: fs_pdfgraphicsobject.h:266
TextState()
Constructor.
Definition: fs_pdfgraphicsobject.h:746
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:195
Shading graphics object.
Definition: fs_pdfgraphicsobject.h:308
Definition: fs_image.h:426
Definition: fs_pdfgraphicsobject.h:890
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:274
bool Transform(const Matrix &matrix, bool need_transform_clippath)
Transform current graphics object.
Color space: DeviceGray.
Definition: fs_pdfgraphicsobject.h:901
Definition: fx_coordinates.h:627
Text mode: neither fill nor stroke text, to make it invisible.
Definition: fs_pdfgraphicsobject.h:704

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