All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Annot.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_CPPPDFAnnot
6 #define PDFTRON_H_CPPPDFAnnot
7 
8 #include <vector>
9 #include <SDF/Obj.h>
10 #include <PDF/Date.h>
11 #include <SDF/SDFDoc.h>
12 #include <PDF/Rect.h>
13 #include <PDF/ColorSpace.h>
14 #include <PDF/FileSpec.h>
15 #include <PDF/Page.h>
16 #include <C/PDF/TRN_Annot.h>
17 #include <PDF/RefreshOptions.h>
18 
19 namespace pdftron {
20  namespace PDF {
21 class BorderStyle;
33 class Annot
34 {
35 public:
41  enum Type
42  {
67  e_3D,
72  };
73 
90  static Annot Create(SDF::SDFDoc& doc, Type type, const Rect& pos);
91 
98  Annot (SDF::Obj d = 0);
99 
103  Annot (const Annot& d);
104 
108  Annot& operator=(const Annot& d);
109 
115  bool operator==(const Annot& d);
116 
122  bool IsValid() const;
123 
127  SDF::Obj GetSDFObj () const;
128 
133  Type GetType() const;
134 
143  Rect GetRect() const;
144 
154  Rect GetVisibleContentBox() const;
155 
161  bool IsMarkup() const;
162 
172  void SetRect(const Rect& pos);
173 
184  Page GetPage() const;
185 
196  void SetPage(const Page& page);
197 
203  SDF::Obj GetUniqueID() const;
204 
211  void SetUniqueID(const char* id, int id_buf_sz = 0);
212 
219  Date GetDate() const;
220 
226  void SetDate(const Date& date);
227 
273  enum Flag
274  {
275  e_invisible, // PDF 1.2
276  e_hidden, // PDF 1.2
277  e_print, // PDF 1.2
278  e_no_zoom, // PDF 1.3
279  e_no_rotate, // PDF 1.3
280  e_no_view, // PDF 1.3
281  e_read_only, // PDF 1.3
282  e_locked, // PDF 1.4
283  e_toggle_no_view, // PDF 1.5
284  e_locked_contents // PDF 1.7
285  };
286 
287 
292  bool GetFlag(Flag flag) const;
293 
300  void SetFlag(Flag flag, bool value);
301 
303  {
304  e_action_trigger_activate = 0, //Triggered when the annotation is activated. if present, takes precedence over U entry (e_action_trigger_annot_up)
305  e_action_trigger_annot_enter = 1, //Triggered when the cursor enters the annotation's active area
306  e_action_trigger_annot_exit = 2, //Triggered when the cursor exits the annotation's active area
307  e_action_trigger_annot_down = 3, //Triggered when the mouse button is pressed inside the annotation’s active area
308  e_action_trigger_annot_up = 4, //Triggered when the mouse button is released inside the annotation’s active area
309  e_action_trigger_annot_focus = 5, //Triggered when the annotation receives the input focus
310  e_action_trigger_annot_blur = 6, //Triggered when the annotation loses the input focus
311  e_action_trigger_annot_page_open = 7, //Triggered when the page containing the annotation is opened
312  e_action_trigger_annot_page_close = 8, //Triggered when the page containing the annotation is closed
313  e_action_trigger_annot_page_visible = 9, //Triggered when the page containing the annotation becomes visible
314  e_action_trigger_annot_page_invisible = 10 //Triggered when the page containing the annotation is no longer visible in the interactive PDF processor’s user interface
315  };
316 
324 
325 
326 
332  BorderStyle GetBorderStyle() const;
333 
344  void SetBorderStyle( const BorderStyle& bs, bool oldStyleOnly = false );
345 
359  {
363  };
364 
382  SDF::Obj GetAppearance(AnnotationState annot_state = e_normal, const char* app_state = 0);
383 
399  void SetAppearance(SDF::Obj app_stream, AnnotationState annot_state = e_normal, const char* app_state = 0);
400 
413  void RemoveAppearance(AnnotationState annot_state = e_normal, const char* app_state = 0);
414 
427  void Flatten(class Page page);
428 
436  const char* GetActiveAppearanceState() const;
437 
446  void SetActiveAppearanceState(const char* astate);
447 
448 
461  ColorPt GetColorAsRGB() const;
462 
475  ColorPt GetColorAsCMYK() const;
476 
487  ColorPt GetColorAsGray() const;
488 
495  int GetColorCompNum() const;
496 
497 
516  void SetColor(const ColorPt& col, int numcomp=3);
517 
518 
529  int GetStructParent() const;
530 
541  void SetStructParent(const int parkeyval);//The value can be set, should be limited.
542 
543 
555 
566  void SetOptionalContent(SDF::Obj content);
567 
575  void SetContents(const UString& contents);
576 
584  UString GetContents() const;
585 
596  int GetRotation() const;
597 
609  void SetRotation(int angle);
610 
628  void RefreshAppearance();
629 
634  void RefreshAppearance(const RefreshOptions& options);
635 
642  UString GetCustomData(const UString& key) const;
643 
650  void SetCustomData(const UString& key, const UString& value);
651 
657  void DeleteCustomData(const UString& key);
658 
668  void Resize(const Rect& newrect);
669 
670  //for xamarin use only
671  static Annot* CreateInternal(ptrdiff_t impl);
672  ptrdiff_t GetHandleInternal();
673 
674  // @cond PRIVATE_DOC
675  #ifndef SWIGHIDDEN
676  Annot(TRN_Annot annot);
677  TRN_Annot mp_annot;
678  #endif
679  // @endcond
680 
681 }; //Class Annot
682 
688 {
689 public:
693  enum Style {
699  };
700 
711  BorderStyle(Style s, double b_width, double b_hr = 0, double b_vr = 0);
725  BorderStyle(Style s, double b_width, double b_hr, double b_vr, const std::vector<double>& b_dash);
726  BorderStyle(const BorderStyle&);
727  ~BorderStyle();
728 
732  void Destroy();
733 
735  friend inline bool operator==(const BorderStyle& a, const BorderStyle& b);
736  friend inline bool operator!=(const BorderStyle& a, const BorderStyle& b) { return !(a == b); }
737 
741  Style GetStyle() const;
742 
746  void SetStyle(Style style);
747 
751  double GetHR() const;
752 
757  void SetHR(double horizontal_radius);
758 
762  double GetVR() const;
763 
768  void SetVR(double vertical_radius);
769 
773  double GetWidth() const;
774 
779  void SetWidth(double width);
780 
785  std::vector<double> GetDash() const;
786 
791  void SetDash(const std::vector<double>& dash);
792 
793  BorderStyle(TRN_AnnotBorderStyle impl);
794  BorderStyle() : mp_bs(0) {}
795 private:
796  friend class PDF::Annot;
797  TRN_AnnotBorderStyle mp_bs;
798 };
799  } //namespace PDF
800 } //namespace pdftron
801 
802 #include <Impl/Page.inl>
803 
804 #endif // PDFTRON_H_CPPPDFAnnot
SDF::Obj GetSDFObj() const
ColorPt GetColorAsGray() const
3D annotation
Definition: Annot.h:67
void SetUniqueID(const char *id, int id_buf_sz=0)
Free text annotation.
Definition: Annot.h:45
void SetWidth(double width)
Any other annotation type, not listed in PDF spec and unrecognized by PDFTron software.
Definition: Annot.h:71
void RemoveAppearance(AnnotationState annot_state=e_normal, const char *app_state=0)
A dashed rectangle surrounding the annotation.
Definition: Annot.h:695
Rect GetRect() const
void SetPage(const Page &page)
friend bool operator==(const BorderStyle &a, const BorderStyle &b)
void SetDate(const Date &date)
Circle annotation.
Definition: Annot.h:48
SDF::Obj GetAppearance(AnnotationState annot_state=e_normal, const char *app_state=0)
ptrdiff_t GetHandleInternal()
Link annotation.
Definition: Annot.h:44
Redact annotation.
Definition: Annot.h:68
int GetRotation() const
Page GetPage() const
Pop-up annotation.
Definition: Annot.h:58
void DeleteCustomData(const UString &key)
Screen annotation.
Definition: Annot.h:63
const char * GetActiveAppearanceState() const
void Resize(const Rect &newrect)
Squiggly-underline annotation.
Definition: Annot.h:53
Ink annotation.
Definition: Annot.h:57
friend bool operator!=(const BorderStyle &a, const BorderStyle &b)
Definition: Annot.h:736
File attachment annotation.
Definition: Annot.h:59
void SetStyle(Style style)
void SetOptionalContent(SDF::Obj content)
Rect GetVisibleContentBox() const
Polyline annotation.
Definition: Annot.h:50
void SetFlag(Flag flag, bool value)
Annot & operator=(const Annot &d)
Watermark annotation.
Definition: Annot.h:66
std::vector< double > GetDash() const
void Flatten(class Page page)
void SetHR(double horizontal_radius)
BorderStyle GetBorderStyle() const
Polygon annotation.
Definition: Annot.h:49
Date GetDate() const
int GetColorCompNum() const
Underline annotation.
Definition: Annot.h:52
void SetBorderStyle(const BorderStyle &bs, bool oldStyleOnly=false)
ColorPt GetColorAsCMYK() const
A simulated embossed rectangle that appears to be raised above the surface of the page...
Definition: Annot.h:696
static Annot * CreateInternal(ptrdiff_t impl)
Movie annotation.
Definition: Annot.h:61
void SetVR(double vertical_radius)
void SetRect(const Rect &pos)
void SetContents(const UString &contents)
void SetAppearance(SDF::Obj app_stream, AnnotationState annot_state=e_normal, const char *app_state=0)
A simulated engraved rectangle that appears to be recessed below the surface of the page...
Definition: Annot.h:697
pdftron::PDF::BorderStyle BorderStyle
Definition: Annot.h:36
Square annotation.
Definition: Annot.h:47
Printer&#39;s mark annotation.
Definition: Annot.h:64
UString GetCustomData(const UString &key) const
double GetWidth() const
A single line along the bottom of the annotation rectangle.
Definition: Annot.h:698
void SetCustomData(const UString &key, const UString &value)
Line annotation.
Definition: Annot.h:46
bool IsMarkup() const
void SetStructParent(const int parkeyval)
Widget annotation.
Definition: Annot.h:62
Annot(SDF::Obj d=0)
void SetRotation(int angle)
Caret annotation.
Definition: Annot.h:56
Trap network annotation.
Definition: Annot.h:65
bool operator==(const Annot &d)
ColorPt GetColorAsRGB() const
Highlight annotation.
Definition: Annot.h:51
void SetActiveAppearanceState(const char *astate)
A solid rectangle surrounding the annotation.
Definition: Annot.h:694
void SetDash(const std::vector< double > &dash)
void SetColor(const ColorPt &col, int numcomp=3)
UString GetContents() const
Type GetType() const
Strikeout annotation.
Definition: Annot.h:54
static Annot Create(SDF::SDFDoc &doc, Type type, const Rect &pos)
SDF::Obj GetOptionalContent() const
Rubber stamp annotation.
Definition: Annot.h:55
int GetStructParent() const
Rich Media annotation, Adobe supplement to ISO 32000.
Definition: Annot.h:70
BorderStyle & operator=(const BorderStyle &)
Projection annotation, Adobe supplement to ISO 32000.
Definition: Annot.h:69
bool GetFlag(Flag flag) const
SDF::Obj GetTriggerAction(Annot::ActionTriggerEvent trigger)
Text annotation.
Definition: Annot.h:43
SDF::Obj GetUniqueID() const
Sound annotation.
Definition: Annot.h:60
bool IsValid() const