Loading...
Searching...
No Matches
Annot.h
Go to the documentation of this file.
1//---------------------------------------------------------------------------------------
2// Copyright (c) 2001-2025 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:
36 typedef pdftron::PDF::BorderStyle BorderStyle;
41 enum Type
42 {
43 e_Text,
44 e_Link,
45 e_FreeText,
46 e_Line,
47 e_Square,
48 e_Circle,
49 e_Polygon,
50 e_Polyline,
51 e_Highlight,
52 e_Underline,
53 e_Squiggly,
54 e_StrikeOut,
55 e_Stamp,
56 e_Caret,
57 e_Ink,
58 e_Popup,
59 e_FileAttachment,
60 e_Sound,
61 e_Movie,
62 e_Widget,
63 e_Screen,
64 e_PrinterMark,
65 e_TrapNet,
66 e_Watermark,
67 e_3D,
68 e_Redact,
69 e_Projection,
70 e_RichMedia,
71 e_Unknown
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
302 enum ActionTriggerEvent
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
323 SDF::Obj GetTriggerAction(Annot::ActionTriggerEvent trigger);
324
325
326
332 BorderStyle GetBorderStyle() const;
333
344 void SetBorderStyle( const BorderStyle& bs, bool oldStyleOnly = false );
345
358 enum AnnotationState
359 {
360 e_normal,
361 e_rollover,
362 e_down
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
554 SDF::Obj GetOptionalContent() const;
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
687 class BorderStyle
688{
689 public:
693 enum Style {
694 e_solid,
695 e_dashed,
696 e_beveled,
697 e_inset,
698 e_underline
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
734 BorderStyle& operator=(const BorderStyle&);
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
ColorSpace.h
Date.h
FileSpec.h
Obj.h
Page.h
Rect.h
RefreshOptions.h
SDFDoc.h
pdftron::PDF::Annot
Definition Annot.h:34
pdftron::PDF::Annot::GetVisibleContentBox
Rect GetVisibleContentBox() const
pdftron::PDF::Annot::Annot
Annot(const Annot &d)
pdftron::PDF::Annot::GetActiveAppearanceState
const char * GetActiveAppearanceState() const
pdftron::PDF::Annot::operator=
Annot & operator=(const Annot &d)
pdftron::PDF::Annot::RefreshAppearance
void RefreshAppearance()
pdftron::PDF::Annot::SetDate
void SetDate(const Date &date)
pdftron::PDF::Annot::GetColorAsCMYK
ColorPt GetColorAsCMYK() const
pdftron::PDF::Annot::SetActiveAppearanceState
void SetActiveAppearanceState(const char *astate)
pdftron::PDF::Annot::GetTriggerAction
SDF::Obj GetTriggerAction(Annot::ActionTriggerEvent trigger)
pdftron::PDF::Annot::RefreshAppearance
void RefreshAppearance(const RefreshOptions &options)
pdftron::PDF::Annot::Type
Type
Definition Annot.h:42
pdftron::PDF::Annot::e_Projection
@ e_Projection
Projection annotation, Adobe supplement to ISO 32000.
Definition Annot.h:69
pdftron::PDF::Annot::e_PrinterMark
@ e_PrinterMark
Printer's mark annotation.
Definition Annot.h:64
pdftron::PDF::Annot::e_Movie
@ e_Movie
Movie annotation.
Definition Annot.h:61
pdftron::PDF::Annot::e_Watermark
@ e_Watermark
Watermark annotation.
Definition Annot.h:66
pdftron::PDF::Annot::e_TrapNet
@ e_TrapNet
Trap network annotation.
Definition Annot.h:65
pdftron::PDF::Annot::e_Widget
@ e_Widget
Widget annotation.
Definition Annot.h:62
pdftron::PDF::Annot::e_Line
@ e_Line
Line annotation.
Definition Annot.h:46
pdftron::PDF::Annot::e_Stamp
@ e_Stamp
Rubber stamp annotation.
Definition Annot.h:55
pdftron::PDF::Annot::e_Square
@ e_Square
Square annotation.
Definition Annot.h:47
pdftron::PDF::Annot::e_Sound
@ e_Sound
Sound annotation.
Definition Annot.h:60
pdftron::PDF::Annot::e_Circle
@ e_Circle
Circle annotation.
Definition Annot.h:48
pdftron::PDF::Annot::e_Polygon
@ e_Polygon
Polygon annotation.
Definition Annot.h:49
pdftron::PDF::Annot::e_Highlight
@ e_Highlight
Highlight annotation.
Definition Annot.h:51
pdftron::PDF::Annot::e_Link
@ e_Link
Link annotation.
Definition Annot.h:44
pdftron::PDF::Annot::e_FreeText
@ e_FreeText
Free text annotation.
Definition Annot.h:45
pdftron::PDF::Annot::e_StrikeOut
@ e_StrikeOut
Strikeout annotation.
Definition Annot.h:54
pdftron::PDF::Annot::e_Redact
@ e_Redact
Redact annotation.
Definition Annot.h:68
pdftron::PDF::Annot::e_Polyline
@ e_Polyline
Polyline annotation.
Definition Annot.h:50
pdftron::PDF::Annot::e_RichMedia
@ e_RichMedia
Rich Media annotation, Adobe supplement to ISO 32000.
Definition Annot.h:70
pdftron::PDF::Annot::e_Caret
@ e_Caret
Caret annotation.
Definition Annot.h:56
pdftron::PDF::Annot::e_FileAttachment
@ e_FileAttachment
File attachment annotation.
Definition Annot.h:59
pdftron::PDF::Annot::e_Ink
@ e_Ink
Ink annotation.
Definition Annot.h:57
pdftron::PDF::Annot::e_3D
@ e_3D
3D annotation
Definition Annot.h:67
pdftron::PDF::Annot::e_Text
@ e_Text
Text annotation.
Definition Annot.h:43
pdftron::PDF::Annot::e_Screen
@ e_Screen
Screen annotation.
Definition Annot.h:63
pdftron::PDF::Annot::e_Squiggly
@ e_Squiggly
Squiggly-underline annotation.
Definition Annot.h:53
pdftron::PDF::Annot::e_Popup
@ e_Popup
Pop-up annotation.
Definition Annot.h:58
pdftron::PDF::Annot::e_Unknown
@ e_Unknown
Any other annotation type, not listed in PDF spec and unrecognized by PDFTron software.
Definition Annot.h:71
pdftron::PDF::Annot::e_Underline
@ e_Underline
Underline annotation.
Definition Annot.h:52
pdftron::PDF::Annot::DeleteCustomData
void DeleteCustomData(const UString &key)
pdftron::PDF::Annot::SetStructParent
void SetStructParent(const int parkeyval)
pdftron::PDF::Annot::SetBorderStyle
void SetBorderStyle(const BorderStyle &bs, bool oldStyleOnly=false)
pdftron::PDF::Annot::GetRotation
int GetRotation() const
pdftron::PDF::Annot::Flag
Flag
Definition Annot.h:274
pdftron::PDF::Annot::e_locked_contents
@ e_locked_contents
Definition Annot.h:284
pdftron::PDF::Annot::e_print
@ e_print
Definition Annot.h:277
pdftron::PDF::Annot::e_no_zoom
@ e_no_zoom
Definition Annot.h:278
pdftron::PDF::Annot::e_no_view
@ e_no_view
Definition Annot.h:280
pdftron::PDF::Annot::e_locked
@ e_locked
Definition Annot.h:282
pdftron::PDF::Annot::e_toggle_no_view
@ e_toggle_no_view
Definition Annot.h:283
pdftron::PDF::Annot::e_no_rotate
@ e_no_rotate
Definition Annot.h:279
pdftron::PDF::Annot::e_hidden
@ e_hidden
Definition Annot.h:276
pdftron::PDF::Annot::e_read_only
@ e_read_only
Definition Annot.h:281
pdftron::PDF::Annot::e_invisible
@ e_invisible
Definition Annot.h:275
pdftron::PDF::Annot::GetPage
Page GetPage() const
pdftron::PDF::Annot::SetRect
void SetRect(const Rect &pos)
pdftron::PDF::Annot::GetBorderStyle
BorderStyle GetBorderStyle() const
pdftron::PDF::Annot::GetType
Type GetType() const
pdftron::PDF::Annot::GetColorAsRGB
ColorPt GetColorAsRGB() const
pdftron::PDF::Annot::operator==
bool operator==(const Annot &d)
pdftron::PDF::Annot::Annot
Annot(SDF::Obj d=0)
pdftron::PDF::Annot::SetRotation
void SetRotation(int angle)
pdftron::PDF::Annot::GetColorAsGray
ColorPt GetColorAsGray() const
pdftron::PDF::Annot::GetColorCompNum
int GetColorCompNum() const
pdftron::PDF::Annot::SetCustomData
void SetCustomData(const UString &key, const UString &value)
pdftron::PDF::Annot::CreateInternal
static Annot * CreateInternal(ptrdiff_t impl)
pdftron::PDF::Annot::SetFlag
void SetFlag(Flag flag, bool value)
pdftron::PDF::Annot::SetContents
void SetContents(const UString &contents)
pdftron::PDF::Annot::GetFlag
bool GetFlag(Flag flag) const
pdftron::PDF::Annot::Flatten
void Flatten(class Page page)
pdftron::PDF::Annot::Create
static Annot Create(SDF::SDFDoc &doc, Type type, const Rect &pos)
pdftron::PDF::Annot::GetSDFObj
SDF::Obj GetSDFObj() const
pdftron::PDF::Annot::AnnotationState
AnnotationState
Definition Annot.h:359
pdftron::PDF::Annot::e_rollover
@ e_rollover
Definition Annot.h:361
pdftron::PDF::Annot::e_normal
@ e_normal
Definition Annot.h:360
pdftron::PDF::Annot::e_down
@ e_down
Definition Annot.h:362
pdftron::PDF::Annot::GetCustomData
UString GetCustomData(const UString &key) const
pdftron::PDF::Annot::SetUniqueID
void SetUniqueID(const char *id, int id_buf_sz=0)
pdftron::PDF::Annot::RemoveAppearance
void RemoveAppearance(AnnotationState annot_state=e_normal, const char *app_state=0)
pdftron::PDF::Annot::IsMarkup
bool IsMarkup() const
pdftron::PDF::Annot::IsValid
bool IsValid() const
pdftron::PDF::Annot::GetDate
Date GetDate() const
pdftron::PDF::Annot::BorderStyle
pdftron::PDF::BorderStyle BorderStyle
Definition Annot.h:36
pdftron::PDF::Annot::GetUniqueID
SDF::Obj GetUniqueID() const
pdftron::PDF::Annot::GetContents
UString GetContents() const
pdftron::PDF::Annot::SetColor
void SetColor(const ColorPt &col, int numcomp=3)
pdftron::PDF::Annot::SetAppearance
void SetAppearance(SDF::Obj app_stream, AnnotationState annot_state=e_normal, const char *app_state=0)
pdftron::PDF::Annot::ActionTriggerEvent
ActionTriggerEvent
Definition Annot.h:303
pdftron::PDF::Annot::e_action_trigger_annot_up
@ e_action_trigger_annot_up
Definition Annot.h:308
pdftron::PDF::Annot::e_action_trigger_annot_page_open
@ e_action_trigger_annot_page_open
Definition Annot.h:311
pdftron::PDF::Annot::e_action_trigger_annot_page_close
@ e_action_trigger_annot_page_close
Definition Annot.h:312
pdftron::PDF::Annot::e_action_trigger_annot_exit
@ e_action_trigger_annot_exit
Definition Annot.h:306
pdftron::PDF::Annot::e_action_trigger_annot_down
@ e_action_trigger_annot_down
Definition Annot.h:307
pdftron::PDF::Annot::e_action_trigger_annot_page_invisible
@ e_action_trigger_annot_page_invisible
Definition Annot.h:314
pdftron::PDF::Annot::e_action_trigger_annot_focus
@ e_action_trigger_annot_focus
Definition Annot.h:309
pdftron::PDF::Annot::e_action_trigger_annot_enter
@ e_action_trigger_annot_enter
Definition Annot.h:305
pdftron::PDF::Annot::e_action_trigger_annot_page_visible
@ e_action_trigger_annot_page_visible
Definition Annot.h:313
pdftron::PDF::Annot::e_action_trigger_activate
@ e_action_trigger_activate
Definition Annot.h:304
pdftron::PDF::Annot::e_action_trigger_annot_blur
@ e_action_trigger_annot_blur
Definition Annot.h:310
pdftron::PDF::Annot::GetHandleInternal
ptrdiff_t GetHandleInternal()
pdftron::PDF::Annot::SetPage
void SetPage(const Page &page)
pdftron::PDF::Annot::GetOptionalContent
SDF::Obj GetOptionalContent() const
pdftron::PDF::Annot::GetStructParent
int GetStructParent() const
pdftron::PDF::Annot::SetOptionalContent
void SetOptionalContent(SDF::Obj content)
pdftron::PDF::Annot::GetRect
Rect GetRect() const
pdftron::PDF::Annot::Resize
void Resize(const Rect &newrect)
pdftron::PDF::Annot::GetAppearance
SDF::Obj GetAppearance(AnnotationState annot_state=e_normal, const char *app_state=0)
pdftron::PDF::BorderStyle
Definition Annot.h:688
pdftron::PDF::BorderStyle::BorderStyle
BorderStyle(Style s, double b_width, double b_hr, double b_vr, const std::vector< double > &b_dash)
pdftron::PDF::BorderStyle::BorderStyle
BorderStyle(Style s, double b_width, double b_hr=0, double b_vr=0)
pdftron::PDF::BorderStyle::operator=
BorderStyle & operator=(const BorderStyle &)
pdftron::PDF::BorderStyle::GetDash
std::vector< double > GetDash() const
pdftron::PDF::BorderStyle::BorderStyle
BorderStyle(TRN_AnnotBorderStyle impl)
pdftron::PDF::BorderStyle::GetHR
double GetHR() const
pdftron::PDF::BorderStyle::SetVR
void SetVR(double vertical_radius)
pdftron::PDF::BorderStyle::SetStyle
void SetStyle(Style style)
pdftron::PDF::BorderStyle::operator!=
friend bool operator!=(const BorderStyle &a, const BorderStyle &b)
Definition Annot.h:736
pdftron::PDF::BorderStyle::GetVR
double GetVR() const
pdftron::PDF::BorderStyle::operator==
friend bool operator==(const BorderStyle &a, const BorderStyle &b)
pdftron::PDF::BorderStyle::GetWidth
double GetWidth() const
pdftron::PDF::BorderStyle::~BorderStyle
~BorderStyle()
pdftron::PDF::BorderStyle::BorderStyle
BorderStyle(const BorderStyle &)
pdftron::PDF::BorderStyle::Destroy
void Destroy()
pdftron::PDF::BorderStyle::BorderStyle
BorderStyle()
Definition Annot.h:794
pdftron::PDF::BorderStyle::GetStyle
Style GetStyle() const
pdftron::PDF::BorderStyle::SetDash
void SetDash(const std::vector< double > &dash)
pdftron::PDF::BorderStyle::SetHR
void SetHR(double horizontal_radius)
pdftron::PDF::BorderStyle::SetWidth
void SetWidth(double width)
pdftron::PDF::BorderStyle::Style
Style
Definition Annot.h:693
pdftron::PDF::BorderStyle::e_dashed
@ e_dashed
A dashed rectangle surrounding the annotation.
Definition Annot.h:695
pdftron::PDF::BorderStyle::e_inset
@ e_inset
A simulated engraved rectangle that appears to be recessed below the surface of the page.
Definition Annot.h:697
pdftron::PDF::BorderStyle::e_beveled
@ e_beveled
A simulated embossed rectangle that appears to be raised above the surface of the page.
Definition Annot.h:696
pdftron::PDF::BorderStyle::e_solid
@ e_solid
A solid rectangle surrounding the annotation.
Definition Annot.h:694
pdftron::PDF::BorderStyle::e_underline
@ e_underline
A single line along the bottom of the annotation rectangle.
Definition Annot.h:698
pdftron::PDF::ColorPt
Definition ColorSpace.h:21
pdftron::PDF::Date
Definition Date.h:29
pdftron::PDF::Page
Definition Page.h:32
pdftron::PDF::Rect
Definition Rect.h:29
pdftron::PDF::RefreshOptions
Definition RefreshOptions.h:9
pdftron::SDF::Obj
Definition Obj.h:41
pdftron::SDF::SDFDoc
Definition SDFDoc.h:68
pdftron::UString
Definition UString.h:28
pdftron::PDF
Definition Action.h:15
pdftron
Definition BasicTypes.h:10