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
19namespace pdftron {
20 namespace PDF {
21class BorderStyle;
33class Annot
34{
35public:
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
109
115 bool operator==(const Annot& d);
116
122 bool IsValid() const;
123
128
133 Type GetType() const;
134
143 Rect GetRect() const;
144
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
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
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
333
344 void SetBorderStyle( const BorderStyle& bs, bool oldStyleOnly = false );
345
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
462
476
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
567
575 void SetContents(const UString& contents);
576
585
596 int GetRotation() const;
597
609 void SetRotation(int angle);
610
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{
689public:
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);
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
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) {}
795private:
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
Rect GetVisibleContentBox() const
Annot(const Annot &d)
const char * GetActiveAppearanceState() const
Annot & operator=(const Annot &d)
void SetDate(const Date &date)
ColorPt GetColorAsCMYK() const
void SetActiveAppearanceState(const char *astate)
SDF::Obj GetTriggerAction(Annot::ActionTriggerEvent trigger)
void RefreshAppearance(const RefreshOptions &options)
@ e_Projection
Projection annotation, Adobe supplement to ISO 32000.
Definition Annot.h:69
@ e_PrinterMark
Printer's mark annotation.
Definition Annot.h:64
@ e_Movie
Movie annotation.
Definition Annot.h:61
@ e_Watermark
Watermark annotation.
Definition Annot.h:66
@ e_TrapNet
Trap network annotation.
Definition Annot.h:65
@ e_Widget
Widget annotation.
Definition Annot.h:62
@ e_Line
Line annotation.
Definition Annot.h:46
@ e_Stamp
Rubber stamp annotation.
Definition Annot.h:55
@ e_Square
Square annotation.
Definition Annot.h:47
@ e_Sound
Sound annotation.
Definition Annot.h:60
@ e_Circle
Circle annotation.
Definition Annot.h:48
@ e_Polygon
Polygon annotation.
Definition Annot.h:49
@ e_Highlight
Highlight annotation.
Definition Annot.h:51
@ e_Link
Link annotation.
Definition Annot.h:44
@ e_FreeText
Free text annotation.
Definition Annot.h:45
@ e_StrikeOut
Strikeout annotation.
Definition Annot.h:54
@ e_Redact
Redact annotation.
Definition Annot.h:68
@ e_Polyline
Polyline annotation.
Definition Annot.h:50
@ e_RichMedia
Rich Media annotation, Adobe supplement to ISO 32000.
Definition Annot.h:70
@ e_Caret
Caret annotation.
Definition Annot.h:56
@ e_FileAttachment
File attachment annotation.
Definition Annot.h:59
@ e_Ink
Ink annotation.
Definition Annot.h:57
@ e_3D
3D annotation
Definition Annot.h:67
@ e_Text
Text annotation.
Definition Annot.h:43
@ e_Screen
Screen annotation.
Definition Annot.h:63
@ e_Squiggly
Squiggly-underline annotation.
Definition Annot.h:53
@ e_Popup
Pop-up annotation.
Definition Annot.h:58
@ e_Unknown
Any other annotation type, not listed in PDF spec and unrecognized by PDFTron software.
Definition Annot.h:71
@ e_Underline
Underline annotation.
Definition Annot.h:52
void DeleteCustomData(const UString &key)
void SetStructParent(const int parkeyval)
void SetBorderStyle(const BorderStyle &bs, bool oldStyleOnly=false)
int GetRotation() const
Page GetPage() const
void SetRect(const Rect &pos)
BorderStyle GetBorderStyle() const
Type GetType() const
ColorPt GetColorAsRGB() const
bool operator==(const Annot &d)
Annot(SDF::Obj d=0)
void SetRotation(int angle)
ColorPt GetColorAsGray() const
int GetColorCompNum() const
void SetCustomData(const UString &key, const UString &value)
static Annot * CreateInternal(ptrdiff_t impl)
void SetFlag(Flag flag, bool value)
void SetContents(const UString &contents)
bool GetFlag(Flag flag) const
void Flatten(class Page page)
static Annot Create(SDF::SDFDoc &doc, Type type, const Rect &pos)
SDF::Obj GetSDFObj() const
UString GetCustomData(const UString &key) const
void SetUniqueID(const char *id, int id_buf_sz=0)
void RemoveAppearance(AnnotationState annot_state=e_normal, const char *app_state=0)
bool IsMarkup() const
bool IsValid() const
Date GetDate() const
pdftron::PDF::BorderStyle BorderStyle
Definition Annot.h:36
SDF::Obj GetUniqueID() const
UString GetContents() const
void SetColor(const ColorPt &col, int numcomp=3)
void SetAppearance(SDF::Obj app_stream, AnnotationState annot_state=e_normal, const char *app_state=0)
@ e_action_trigger_annot_up
Definition Annot.h:308
@ e_action_trigger_annot_page_open
Definition Annot.h:311
@ e_action_trigger_annot_page_close
Definition Annot.h:312
@ e_action_trigger_annot_exit
Definition Annot.h:306
@ e_action_trigger_annot_down
Definition Annot.h:307
@ e_action_trigger_annot_page_invisible
Definition Annot.h:314
@ e_action_trigger_annot_focus
Definition Annot.h:309
@ e_action_trigger_annot_enter
Definition Annot.h:305
@ e_action_trigger_annot_page_visible
Definition Annot.h:313
@ e_action_trigger_activate
Definition Annot.h:304
@ e_action_trigger_annot_blur
Definition Annot.h:310
ptrdiff_t GetHandleInternal()
void SetPage(const Page &page)
SDF::Obj GetOptionalContent() const
int GetStructParent() const
void SetOptionalContent(SDF::Obj content)
Rect GetRect() const
void Resize(const Rect &newrect)
SDF::Obj GetAppearance(AnnotationState annot_state=e_normal, const char *app_state=0)
BorderStyle(Style s, double b_width, double b_hr, double b_vr, const std::vector< double > &b_dash)
BorderStyle(Style s, double b_width, double b_hr=0, double b_vr=0)
BorderStyle & operator=(const BorderStyle &)
std::vector< double > GetDash() const
BorderStyle(TRN_AnnotBorderStyle impl)
void SetVR(double vertical_radius)
void SetStyle(Style style)
friend bool operator!=(const BorderStyle &a, const BorderStyle &b)
Definition Annot.h:736
friend bool operator==(const BorderStyle &a, const BorderStyle &b)
BorderStyle(const BorderStyle &)
void SetDash(const std::vector< double > &dash)
void SetHR(double horizontal_radius)
void SetWidth(double width)
@ e_dashed
A dashed rectangle surrounding the annotation.
Definition Annot.h:695
@ e_inset
A simulated engraved rectangle that appears to be recessed below the surface of the page.
Definition Annot.h:697
@ e_beveled
A simulated embossed rectangle that appears to be raised above the surface of the page.
Definition Annot.h:696
@ e_solid
A solid rectangle surrounding the annotation.
Definition Annot.h:694
@ e_underline
A single line along the bottom of the annotation rectangle.
Definition Annot.h:698