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-2020 by PDFTron Systems 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 
598  void SetDashPattern(const std::vector<double>& dash_array, double phase);
599 
607  void SetCharSpacing(double char_spacing);
608 
615  void SetWordSpacing(double word_spacing);
616 
626  void SetHorizontalScale(double hscale);
627 
636  void SetLeading(double leading);
637 
643  void SetFont(Font font, double font_sz);
644 
652 
660  void SetTextRise(double rise);
661 
667  void SetTextKnockout(bool knockout);
668 
672  void SetRenderingIntent(RenderingIntent intent);
673 
674  // Extended graphics state 'Set' methods ----------------------------------------
675 
689  void SetBlendMode(BlendMode BM);
690 
696  void SetFillOpacity(double ca);
697 
703  void SetStrokeOpacity(double ca);
704 
712  void SetAISFlag(bool AIS);
713 
719  void SetSoftMask(SDF::Obj SM);
720 
726  void SetStrokeOverprint(bool OP);
727 
733  void SetFillOverprint(bool op);
734 
740  void SetOverprintMode(int OPM);
741 
747  void SetAutoStrokeAdjust(bool SA);
748 
754  void SetSmoothnessTolerance(double SM);
755 
762  void SetBlackGenFunct(SDF::Obj BG);
763 
770  void SetUCRFunct(SDF::Obj UCR);
771 
779  void SetTransferFunct(SDF::Obj TR);
780 
788  void SetHalftone(SDF::Obj HT);
789 
790 // @cond PRIVATE_DOC
791 #ifndef SWIGHIDDEN
792  GState(TRN_GState impl);
793  TRN_GState mp_state;
794 #endif
795 // @endcond
796 };
797 
798 
799 #include <Impl/GState.inl>
800 
801  }; // namespace PDF
802 }; // namespace pdftron
803 
804 
805 
806 // @cond PRIVATE_DOC
807 #ifndef SWIGHIDDEN
808 #ifdef _WIN32
809  // A forward declaration for GDI+
810  namespace Gdiplus { class Bitmap; };
811 #endif
812 #endif
813 // @endcond
814 
815 #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)