All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GState.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------------------
2 // Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
3 // Consult legal.txt regarding legal and license information.
4 //---------------------------------------------------------------------------------------
5 #ifndef PDFTRON_H_CPPPDFGState
6 #define PDFTRON_H_CPPPDFGState
7 
8 #include <C/PDF/TRN_GState.h>
9 #include <Common/Matrix2D.h>
10 #include <PDF/ColorSpace.h>
11 #include <PDF/Font.h>
12 #include <PDF/PatternColor.h>
13 
14 namespace pdftron {
15  namespace PDF {
16 
26 class GState
27 {
28 public:
29 
30  GState();
31  GState(const GState& c);
32  GState& operator=(const GState& c);
33 
34  // GState properties
36  {
37  e_transform = 0, // General graphics state attributes
39 
44 
45  e_line_width, // Path attributes
51 
52  e_char_spacing, // Text attributes
61 
62  // Adjusts the text position by a given amount. The attribute can be
63  // accessed through Element interface
65 
66  e_blend_mode, // Extended graphics state attributes
80 
81  // null attribute
83  };
84 
85  // Get Methods ------------------------------------------------------------------
86 
93 
98 
103 
108 
113 
118 
123 
134  double GetFlatness() const;
135 
136 
137  enum LineCap
138  {
139  e_butt_cap = 0, // The stroke is squared off at the endpoint of the path.
140  e_round_cap, // A semicircular arc with a diameter equal to the line width.
141  e_square_cap // squared off stroke continues beyond the endpoint of the path.
142  };
143 
150  LineCap GetLineCap() const;
151 
152 
153  enum LineJoin
154  {
155  e_miter_join = 0, // The two segments are extended until they meet
156  e_round_join, // A circle with a diameter equal to the line width
157  e_bevel_join // The two segments are finished with butt caps
158  };
159 
166  LineJoin GetLineJoin() const;
167 
173  double GetLineWidth() const;
174 
182  double GetMiterLimit() const;
183 
193  std::vector<double> GetDashes() const;
194 
195 #ifndef SWIG
196  void GetDashes(std::vector<double>& dashes) const;
197 #endif
198 
203  double GetPhase() const;
204 
213  double GetCharSpacing() const;
214 
221  double GetWordSpacing() const;
222 
232  double GetHorizontalScale() const;
233 
241  double GetLeading() const;
242 
246  Font GetFont() const;
247 
251  double GetFontSize() const;
252 
254  {
255  e_fill_text = 0, // Fill text.
256  e_stroke_text, // Stroke text.
257  e_fill_stroke_text, // Fill, then stroke text.
258  e_invisible_text, // Neither fill nor stroke text (invisible).
259  e_fill_clip_text, // Fill text and add to path for clipping (see above).
260  e_stroke_clip_text, // Stroke text and add to path for clipping.
261  e_fill_stroke_clip_text, // Fill, then stroke text and add to path for clipping.
262  e_clip_text // Add text to path for clipping.
263  };
264 
273 
281  double GetTextRise() const;
282 
288  bool IsTextKnockout() const;
289 
291  {
296  };
297 
302 
309  static RenderingIntent GetRenderingIntentType(const char* name);
310 
311  // Extended graphics state 'Get' methods ----------------------------------------
312 
313  // The standard separable blend modes available in PDF.
315  {
333  };
334 
340 
346  double GetFillOpacity() const;
347 
353  double GetStrokeOpacity() const;
354 
360  bool GetAISFlag() const;
361 
367 
375 
380  bool GetStrokeOverprint() const;
381 
386  bool GetFillOverprint() const;
387 
392  int GetOverprintMode() const;
393 
398  bool GetAutoStrokeAdjust() const;
399 
406  double GetSmoothnessTolerance() const;
407 
415 
422 
429 
437 
438  // Set Methods ------------------------------------------------------------------
439 
448  void SetTransform(const Common::Matrix2D& mtx);
449 
468  void SetTransform(double a, double b, double c, double d, double h, double v);
469 
474  void Concat(const Common::Matrix2D& mtx);
485  void Concat(double a, double b, double c, double d, double h, double v);
486 
492 
497  void SetFillColorSpace(ColorSpace cs);
498 
505  void SetStrokeColor(const ColorPt& c);
506 
512  void SetStrokeColor(PatternColor pattern);
513 
520  void SetStrokeColor(PatternColor pattern, const ColorPt& c);
521 
528  void SetFillColor(const ColorPt& c);
529 
535  void SetFillColor(PatternColor pattern);
536 
543  void SetFillColor(PatternColor pattern, const ColorPt& c);
544 
555  void SetFlatness(double flatness);
556 
563  void SetLineCap(LineCap cap);
564 
571  void SetLineJoin(LineJoin join);
572 
579  void SetLineWidth(double width);
580 
587  void SetMiterLimit(double miter_limit);
588 
597  void SetDashPattern(const std::vector<double>& dash_array, double phase);
598 
606  void SetCharSpacing(double char_spacing);
607 
614  void SetWordSpacing(double word_spacing);
615 
625  void SetHorizontalScale(double hscale);
626 
635  void SetLeading(double leading);
636 
642  void SetFont(Font font, double font_sz);
643 
651 
659  void SetTextRise(double rise);
660 
666  void SetTextKnockout(bool knockout);
667 
671  void SetRenderingIntent(RenderingIntent intent);
672 
673  // Extended graphics state 'Set' methods ----------------------------------------
674 
688  void SetBlendMode(BlendMode BM);
689 
695  void SetFillOpacity(double ca);
696 
702  void SetStrokeOpacity(double ca);
703 
711  void SetAISFlag(bool AIS);
712 
718  void SetSoftMask(SDF::Obj SM);
719 
725  void SetStrokeOverprint(bool OP);
726 
732  void SetFillOverprint(bool op);
733 
739  void SetOverprintMode(int OPM);
740 
746  void SetAutoStrokeAdjust(bool SA);
747 
753  void SetSmoothnessTolerance(double SM);
754 
761  void SetBlackGenFunct(SDF::Obj BG);
762 
769  void SetUCRFunct(SDF::Obj UCR);
770 
778  void SetTransferFunct(SDF::Obj TR);
779 
787  void SetHalftone(SDF::Obj HT);
788 
789 // @cond PRIVATE_DOC
790 #ifndef SWIGHIDDEN
791  GState(TRN_GState impl);
792  TRN_GState mp_state;
793 #endif
794 // @endcond
795 };
796 
797 
798 #include <Impl/GState.inl>
799 
800  }; // namespace PDF
801 }; // namespace pdftron
802 
803 
804 
805 // @cond PRIVATE_DOC
806 #ifndef SWIGHIDDEN
807 #ifdef _WIN32
808  // A forward declaration for GDI+
809  namespace Gdiplus { class Bitmap; };
810 #endif
811 #endif
812 // @endcond
813 
814 #endif // PDFTRON_H_CPPPDFGState
void SetSoftMask(SDF::Obj SM)
double GetHorizontalScale() const
void SetLeading(double leading)
void SetHalftone(SDF::Obj HT)
PatternColor GetFillPattern()
double GetLeading() const
bool IsTextKnockout() const
SDF::Obj GetSoftMask()
void SetStrokeColorSpace(ColorSpace cs)
void SetCharSpacing(double char_spacing)
std::vector< double > GetDashes() const
double GetSmoothnessTolerance() const
void SetAISFlag(bool AIS)
void SetTextRise(double rise)
RenderingIntent GetRenderingIntent() const
SDF::Obj GetTransferFunct()
static RenderingIntent GetRenderingIntentType(const char *name)
ColorSpace GetFillColorSpace()
void SetSmoothnessTolerance(double SM)
double GetFlatness() const
LineCap GetLineCap() const
void SetTextRenderMode(TextRenderingMode rmode)
double GetLineWidth() const
Common::Matrix2D GetTransform()
BlendMode GetBlendMode()
double GetCharSpacing() const
SDF::Obj GetHalftone()
bool GetFillOverprint() const
void SetLineJoin(LineJoin join)
void SetLineCap(LineCap cap)
void SetTransferFunct(SDF::Obj TR)
void SetStrokeColor(const ColorPt &c)
ColorPt GetStrokeColor()
void SetStrokeOpacity(double ca)
void SetBlendMode(BlendMode BM)
void SetFillColorSpace(ColorSpace cs)
Common::Matrix2D GetSoftMaskTransform()
void SetHorizontalScale(double hscale)
ColorSpace GetStrokeColorSpace()
double GetPhase() const
void SetStrokeOverprint(bool OP)
bool GetAISFlag() const
double GetMiterLimit() const
void SetOverprintMode(int OPM)
void Concat(const Common::Matrix2D &mtx)
void SetBlackGenFunct(SDF::Obj BG)
void SetTextKnockout(bool knockout)
void SetFlatness(double flatness)
int GetOverprintMode() const
void SetFillColor(const ColorPt &c)
void SetTransform(const Common::Matrix2D &mtx)
double GetFillOpacity() const
void SetUCRFunct(SDF::Obj UCR)
double GetTextRise() const
void SetLineWidth(double width)
SDF::Obj GetUCRFunct()
LineJoin GetLineJoin() const
double GetWordSpacing() const
PatternColor GetStrokePattern()
void SetRenderingIntent(RenderingIntent intent)
GState & operator=(const GState &c)
void SetFont(Font font, double font_sz)
bool GetAutoStrokeAdjust() const
TextRenderingMode GetTextRenderMode() const
void SetMiterLimit(double miter_limit)
Font GetFont() const
void SetAutoStrokeAdjust(bool SA)
void SetWordSpacing(double word_spacing)
double GetFontSize() const
void SetFillOpacity(double ca)
SDF::Obj GetBlackGenFunct()
void SetFillOverprint(bool op)
double GetStrokeOpacity() const
bool GetStrokeOverprint() const
void SetDashPattern(const std::vector< double > &dash_array, double phase)