All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Element.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------------------
2 // Copyright (c) 2001-2023 by Apryse Software Inc. All Rights Reserved.
3 // Consult legal.txt regarding legal and license information.
4 //---------------------------------------------------------------------------------------
5 #ifndef PDFTRON_H_CPPPDFElement
6 #define PDFTRON_H_CPPPDFElement
7 
8 #include <SDF/Obj.h>
9 #include <PDF/GState.h>
10 #include <PDF/Rect.h>
11 #include <PDF/CharData.h>
12 #include <PDF/PathData.h>
13 #include <PDF/Struct/SElement.h>
14 #include <C/PDF/TRN_Element.h>
15 
16 namespace pdftron {
17  namespace PDF {
18 
19 
32 class Element
33 {
34 public:
35  // Common Methods ---------------------------------------------------------------
36 
37  enum Type
38  {
39  e_null, // undefined element type
40  e_path, // path object
41  e_text_begin, // marks the beginning of a text container
42  e_text, // text object within a text container
43  e_text_new_line, // indicates the start of the new text line
44  e_text_end, // marks the end of text container
45  e_image, // image XObject
46  e_inline_image, // inline image object
47  e_shading, // shading object
48  e_form, // a form XObject
49  e_group_begin, // push graphics state operator (q)
50  e_group_end, // pop graphics state operator (Q)
51  e_marked_content_begin, // marks the beginning of marked content sequence (BMC, BDC)
52  e_marked_content_end, // marks the end of marked content sequence (EMC)
53  e_marked_content_point // designate a marked-content point (MP, DP)
54  };
55 
56  Element();
57  Element(const Element& c);
58  Element& operator=(const Element&c);
59  operator bool () { return mp_elem!=0;}
60 
64  Type GetType();
65 
69  GState GetGState();
70 
76 
97  Rect GetBBox();
98 
99 #ifndef SWIG
100  bool GetBBox(Rect& out_bbox);
101 #endif
102 
109 
117  int GetStructMCID();
118 
129  bool IsOCVisible();
130 
131  // Path Element (e_path) Get Methods --------------------------------------------
132 
137  bool IsClippingPath();
138 
142  bool IsStroked();
143 
147  bool IsFilled();
148 
166  bool IsWindingFill();
167 
172  bool IsClipWindingFill();
173 
179  PathData GetPathData() const;
180 
181  // Path Element (e_path) Set Methods --------------------------------------------
182 
187  void SetPathData(const PathData& data);
188 
193  void SetPathClip(bool clip);
194 
199  void SetPathStroke(bool stroke);
200 
205  void SetPathFill(bool fill);
206 
212  void SetWindingFill(bool winding_rule);
213 
219  void SetClipWindingFill(bool winding_rule);
220 
221  // XObject Element (e_image or e_form_begin) Methods ----------------------------
222 
227 
228 
229  // Image (e_image and e_inline_image) Element Methods ---------------------------
230 
235 
239  int GetImageDataSize() const;
240 
252  #if defined(_WIN32)
253  Gdiplus::Bitmap* GetBitmap() const;
254  #endif
255 
263 
267  int GetImageWidth() const;
268 
272  int GetImageHeight() const;
273 
282  SDF::Obj GetDecodeArray() const;
283 
289  int GetBitsPerComponent() const;
290 
294  int GetComponentNum() const;
295 
296 
300  bool IsImageMask() const;
301 
305  bool IsImageInterpolate() const;
306 
314  SDF::Obj GetMask() const;
315 
320 
321  // Text Element (e_text) Get Methods --------------------------------------------
322 
341 
356 #ifdef SWIG
357  std::vector<unsigned char> GetTextData();
358 #else
359  const UChar* GetTextData();
360 #endif
361 
366 
371 
403 
418  double GetTextLength();
419 
429  double GetPosAdjustment();
430 
431  // Text New Line Element (e_text_new_line) Methods ------------------------------
432 
441 
442 #ifndef SWIG
443  void GetNewTextLineOffset(double& out_x, double& out_y);
444 #endif
445 
452  void SetNewTextLineOffset(double dx, double dy);
453 
454 
455  // Text Element (e_text and e_text_new_line) Methods ----------------------------
456 
462  bool HasTextMatrix();
463 
464 
465  // Text Element (e_text) Set Methods --------------------------------------------
466 
472  void SetTextData(const UChar* buf_text_data, int text_data_size);
473 
479  void SetTextMatrix(Common::Matrix2D& mtx);
480 
500  void SetTextMatrix(double a, double b, double c, double d, double h, double v);
501 
508  void SetPosAdjustment(double adjust);
509 
519  void UpdateTextMetrics();
520 
521 
522  // Shading Element (e_shading) Methods ------------------------------------------
523 
528 
529  // Marked Content Elements
530  // (e_marked_content_begin and e_marked_content_point) Methods ------------------
531 
541 
546  SDF::Obj GetMCTag();
547 
548  ~Element() {}
549 
550 
551 // @cond PRIVATE_DOC
552 #ifndef SWIGHIDDEN
553  Element(TRN_Element impl);
554  TRN_Element mp_elem;
555 #endif
556 // @endcond
557 };
558 
559 
560 #include <Impl/Element.inl>
561 
562  }; // namespace PDF
563 }; // namespace pdftron
564 
565 #endif // PDFTRON_H_CPPPDFElement
bool IsImageInterpolate() const
CharIterator GetCharIterator()
void SetTextMatrix(Common::Matrix2D &mtx)
void SetPathClip(bool clip)
void SetPathStroke(bool stroke)
Filters::Filter GetImageData() const
void SetPathFill(bool fill)
void SetPathData(const PathData &data)
SDF::Obj GetMCPropertyDict()
bool IsImageMask() const
Common::Matrix2D GetTextMatrix()
GState::RenderingIntent GetImageRenderingIntent() const
int GetBitsPerComponent() const
void SetWindingFill(bool winding_rule)
int GetImageHeight() const
Common::Matrix2D GetCTM()
ColorSpace GetImageColorSpace() const
TRN_UInt32 UInt32
Definition: BasicTypes.h:13
int GetImageWidth() const
const UChar * GetTextData()
TRN_UChar UChar
Definition: BasicTypes.h:12
SDF::Obj GetDecodeArray() const
Gdiplus::Bitmap * GetBitmap() const
int GetComponentNum() const
PathData GetPathData() const
Struct::SElement GetParentStructElement()
void SetNewTextLineOffset(double dx, double dy)
Element & operator=(const Element &c)
int GetImageDataSize() const
void SetClipWindingFill(bool winding_rule)
SDF::Obj GetMask() const
void SetPosAdjustment(double adjust)
void SetTextData(const UChar *buf_text_data, int text_data_size)