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-2018 by PDFTron Systems 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 
18 namespace pdftron {
19  namespace PDF {
20 
32 class Annot
33 {
34 public:
35 
40  enum Type
41  {
66  e_3D,
71  };
72 
89  static Annot Create(SDF::SDFDoc& doc, Type type, const Rect& pos);
90 
97  Annot (SDF::Obj d = 0);
98 
102  Annot (const Annot& d);
103 
107  Annot& operator=(const Annot& d);
108 
114  bool operator==(const Annot& d);
115 
121  bool IsValid() const;
122 
126  SDF::Obj GetSDFObj () const;
127 
132  Type GetType() const;
133 
142  Rect GetRect() const;
143 
153  Rect GetVisibleContentBox() const;
154 
160  bool IsMarkup() const;
161 
171  void SetRect(const Rect& pos);
172 
183  Page GetPage() const;
184 
195  void SetPage(const Page& page);
196 
202  SDF::Obj GetUniqueID() const;
203 
210  void SetUniqueID(const char* id, int id_buf_sz = 0);
211 
218  Date GetDate() const;
219 
225  void SetDate(const Date& date);
226 
272  enum Flag
273  {
274  e_invisible, // PDF 1.2
275  e_hidden, // PDF 1.2
276  e_print, // PDF 1.2
277  e_no_zoom, // PDF 1.3
278  e_no_rotate, // PDF 1.3
279  e_no_view, // PDF 1.3
280  e_read_only, // PDF 1.3
281  e_locked, // PDF 1.4
282  e_toggle_no_view, // PDF 1.5
283  e_locked_contents // PDF 1.7
284  };
285 
286 
291  bool GetFlag(Flag flag) const;
292 
299  void SetFlag(Flag flag, bool value);
300 
302  {
303  e_action_trigger_activate = 0, //Triggered when the annotation is activated. if present, takes precedence over U entry (e_action_trigger_annot_up)
304  e_action_trigger_annot_enter = 1, //Triggered when the cursor enters the annotation's active area
305  e_action_trigger_annot_exit = 2, //Triggered when the cursor exits the annotation's active area
306  e_action_trigger_annot_down = 3, //Triggered when the mouse button is pressed inside the annotation’s active area
307  e_action_trigger_annot_up = 4, //Triggered when the mouse button is released inside the annotation’s active area
308  e_action_trigger_annot_focus = 5, //Triggered when the annotation receives the input focus
309  e_action_trigger_annot_blur = 6, //Triggered when the annotation loses the input focus
310  e_action_trigger_annot_page_open = 7, //Triggered when the page containing the annotation is opened
311  e_action_trigger_annot_page_close = 8, //Triggered when the page containing the annotation is closed
312  e_action_trigger_annot_page_visible = 9, //Triggered when the page containing the annotation becomes visible
313  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
314  };
315 
323 
329  {
330  public:
334  enum Style {
340  };
341 
355  BorderStyle(Style s, double b_width, double b_hr =0, double b_vr =0);
356  BorderStyle(Style s, double b_width, double b_hr, double b_vr, const std::vector<double>& b_dash);
357  BorderStyle(const BorderStyle&);
358  ~BorderStyle();
359 
363  void Destroy();
364 
366  friend inline bool operator==( const BorderStyle& a, const BorderStyle& b );
367  friend inline bool operator!=( const BorderStyle& a, const BorderStyle& b ) { return !( a == b ); }
368 
372  Style GetStyle() const;
373 
377  void SetStyle(Style style);
378 
382  double GetHR() const;
383 
388  void SetHR(double horizontal_radius);
389 
393  double GetVR() const;
394 
399  void SetVR(double vertical_radius);
400 
404  double GetWidth() const;
405 
410  void SetWidth(double width);
411 
416  std::vector<double> GetDash() const;
417 
422  void SetDash( const std::vector<double>& dash);
423 
424  BorderStyle(TRN_AnnotBorderStyle impl);
425  BorderStyle() : mp_bs(0) {}
426  private:
427  friend class PDF::Annot;
428  TRN_AnnotBorderStyle mp_bs;
429  };
430 
436  BorderStyle GetBorderStyle() const;
437 
448  void SetBorderStyle( const BorderStyle& bs, bool oldStyleOnly = false );
449 
463  {
467  };
468 
486  SDF::Obj GetAppearance(AnnotationState annot_state = e_normal, const char* app_state = 0);
487 
503  void SetAppearance(SDF::Obj app_stream, AnnotationState annot_state = e_normal, const char* app_state = 0);
504 
517  void RemoveAppearance(AnnotationState annot_state = e_normal, const char* app_state = 0);
518 
531  void Flatten(class Page page);
532 
540  const char* GetActiveAppearanceState() const;
541 
550  void SetActiveAppearanceState(const char* astate);
551 
552 
565  ColorPt GetColorAsRGB() const;
566 
579  ColorPt GetColorAsCMYK() const;
580 
591  ColorPt GetColorAsGray() const;
592 
599  int GetColorCompNum() const;
600 
601 
620  void SetColor(const ColorPt& col, int numcomp=3);
621 
622 
633  int GetStructParent() const;
634 
645  void SetStructParent(const int parkeyval);//The value can be set, should be limited.
646 
647 
659 
670  void SetOptionalContent(SDF::Obj content);
671 
679  void SetContents(const UString& contents);
680 
688  UString GetContents() const;
689 
706  int GetRotation() const;
707 
719  void SetRotation(int angle);
720 
738  void RefreshAppearance();
739 
749  void Resize(const Rect& newrect);
750 
751  //for xamarin use only
752  static Annot* CreateInternal(ptrdiff_t impl);
753  ptrdiff_t GetHandleInternal();
754 
756  #ifndef SWIGHIDDEN
757  Annot(TRN_Annot annot);
758  TRN_Annot mp_annot;
759  #endif
760 
762 }; //Class Annot
763 
764 
765  } //namespace PDF
766 } //namespace pdftron
767 
768 #include <Impl/Page.inl>
769 
770 #endif // PDFTRON_H_CPPPDFAnnot
SDF::Obj GetSDFObj() const
std::vector< double > GetDash() const
ColorPt GetColorAsGray() const
3D annotation
Definition: Annot.h:66
void SetUniqueID(const char *id, int id_buf_sz=0)
Free text annotation.
Definition: Annot.h:44
Any other annotation type, not listed in PDF spec and unrecognized by PDFTron software.
Definition: Annot.h:70
void RemoveAppearance(AnnotationState annot_state=e_normal, const char *app_state=0)
void SetVR(double vertical_radius)
Rect GetRect() const
void SetPage(const Page &page)
void SetDate(const Date &date)
Circle annotation.
Definition: Annot.h:47
friend bool operator==(const BorderStyle &a, const BorderStyle &b)
void SetHR(double horizontal_radius)
SDF::Obj GetAppearance(AnnotationState annot_state=e_normal, const char *app_state=0)
ptrdiff_t GetHandleInternal()
Link annotation.
Definition: Annot.h:43
A dashed rectangle surrounding the annotation.
Definition: Annot.h:336
Redact annotation.
Definition: Annot.h:67
int GetRotation() const
Page GetPage() const
Pop-up annotation.
Definition: Annot.h:57
Screen annotation.
Definition: Annot.h:62
const char * GetActiveAppearanceState() const
void Resize(const Rect &newrect)
Squiggly-underline annotation.
Definition: Annot.h:52
Ink annotation.
Definition: Annot.h:56
void SetDash(const std::vector< double > &dash)
File attachment annotation.
Definition: Annot.h:58
A simulated embossed rectangle that appears to be raised above the surface of the page...
Definition: Annot.h:337
void SetOptionalContent(SDF::Obj content)
Rect GetVisibleContentBox() const
Polyline annotation.
Definition: Annot.h:49
void SetFlag(Flag flag, bool value)
Annot & operator=(const Annot &d)
Watermark annotation.
Definition: Annot.h:65
void Flatten(class Page page)
BorderStyle GetBorderStyle() const
Polygon annotation.
Definition: Annot.h:48
Date GetDate() const
int GetColorCompNum() const
Underline annotation.
Definition: Annot.h:51
void SetBorderStyle(const BorderStyle &bs, bool oldStyleOnly=false)
ColorPt GetColorAsCMYK() const
static Annot * CreateInternal(ptrdiff_t impl)
Movie annotation.
Definition: Annot.h:60
void SetRect(const Rect &pos)
BorderStyle & operator=(const BorderStyle &)
void SetContents(const UString &contents)
void SetAppearance(SDF::Obj app_stream, AnnotationState annot_state=e_normal, const char *app_state=0)
Square annotation.
Definition: Annot.h:46
Printer&#39;s mark annotation.
Definition: Annot.h:63
Line annotation.
Definition: Annot.h:45
bool IsMarkup() const
void SetStructParent(const int parkeyval)
Widget annotation.
Definition: Annot.h:61
Annot(SDF::Obj d=0)
void SetRotation(int angle)
A single line along the bottom of the annotation rectangle.
Definition: Annot.h:339
Caret annotation.
Definition: Annot.h:55
Trap network annotation.
Definition: Annot.h:64
bool operator==(const Annot &d)
ColorPt GetColorAsRGB() const
Highlight annotation.
Definition: Annot.h:50
void SetActiveAppearanceState(const char *astate)
void SetColor(const ColorPt &col, int numcomp=3)
UString GetContents() const
Type GetType() const
Strikeout annotation.
Definition: Annot.h:53
static Annot Create(SDF::SDFDoc &doc, Type type, const Rect &pos)
SDF::Obj GetOptionalContent() const
Rubber stamp annotation.
Definition: Annot.h:54
int GetStructParent() const
Rich Media annotation, Adobe supplement to ISO 32000.
Definition: Annot.h:69
A simulated engraved rectangle that appears to be recessed below the surface of the page...
Definition: Annot.h:338
Projection annotation, Adobe supplement to ISO 32000.
Definition: Annot.h:68
A solid rectangle surrounding the annotation.
Definition: Annot.h:335
bool GetFlag(Flag flag) const
friend bool operator!=(const BorderStyle &a, const BorderStyle &b)
Definition: Annot.h:367
SDF::Obj GetTriggerAction(Annot::ActionTriggerEvent trigger)
Text annotation.
Definition: Annot.h:42
SDF::Obj GetUniqueID() const
Sound annotation.
Definition: Annot.h:59
bool IsValid() const

© 2002-2014 PDFTron Systems Inc.