5#ifndef PDF_ANNOTATION_H
6#define PDF_ANNOTATION_H
9#include <podofo/auxiliary/Rect.h>
16class PdfAnnotationText;
17class PdfAnnotationLink;
18class PdfAnnotationFreeText;
19class PdfAnnotationLine;
20class PdfAnnotationSquare;
21class PdfAnnotationCircle;
22class PdfAnnotationPolygon;
23class PdfAnnotationPolyLine;
24class PdfAnnotationHighlight;
25class PdfAnnotationUnderline;
26class PdfAnnotationSquiggly;
27class PdfAnnotationStrikeOut;
28class PdfAnnotationStamp;
29class PdfAnnotationCaret;
30class PdfAnnotationInk;
31class PdfAnnotationPopup;
32class PdfAnnotationFileAttachment;
33class PdfAnnotationSound;
34class PdfAnnotationMovie;
35class PdfAnnotationWidget;
36class PdfAnnotationScreen;
37class PdfAnnotationPrinterMark;
38class PdfAnnotationTrapNet;
39class PdfAnnotationWatermark;
40class PdfAnnotationModel3D;
41class PdfAnnotationRichMedia;
42class PdfAnnotationWebMedia;
43class PdfAnnotationRedact;
44class PdfAnnotationProjection;
69 friend class PdfAnnotationCollection;
70 friend class PdfAnnotationTextMarkupBase;
71 friend class PdfAnnotationPopup;
72 friend class PdfAnnotationText;
73 friend class PdfAnnotationCaret;
74 friend class PdfAnnotationFileAttachment;
75 friend class PdfAnnotationFreeText;
76 friend class PdfAnnotationHighlight;
77 friend class PdfAnnotationInk;
78 friend class PdfAnnotationLine;
79 friend class PdfAnnotationModel3D;
80 friend class PdfAnnotationMovie;
81 friend class PdfAnnotationPolygon;
82 friend class PdfAnnotationPolyLine;
83 friend class PdfAnnotationPrinterMark;
84 friend class PdfAnnotationRichMedia;
85 friend class PdfAnnotationScreen;
86 friend class PdfAnnotationSquiggly;
87 friend class PdfAnnotationStrikeOut;
88 friend class PdfAnnotationSound;
89 friend class PdfAnnotationSquare;
90 friend class PdfAnnotationCircle;
91 friend class PdfAnnotationStamp;
92 friend class PdfAnnotationTrapNet;
93 friend class PdfAnnotationUnderline;
94 friend class PdfAnnotationWatermark;
95 friend class PdfAnnotationWebMedia;
96 friend class PdfAnnotationRedact;
97 friend class PdfAnnotationProjection;
98 friend class PdfAnnotationActionBase;
99 friend class PdfToggleButton;
107 static bool TryCreateFromObject(
PdfObject&
obj, std::unique_ptr<PdfAnnotation>&
xobj);
109 static bool TryCreateFromObject(
const PdfObject&
obj, std::unique_ptr<const PdfAnnotation>&
xobj);
111 template <
typename TAnnotation>
112 static bool TryCreateFromObject(
PdfObject&
obj, std::unique_ptr<TAnnotation>&
xobj);
114 template <
typename TAnnotation>
115 static bool TryCreateFromObject(
const PdfObject&
obj, std::unique_ptr<const TAnnotation>&
xobj);
136 [[deprecated(
"Use the SetAppearanceStream methods with flags instead")]]
146 [[deprecated(
"Use the SetAppearanceStream methods with flags instead")]]
152 void GetAppearanceStreams(std::vector<PdfAppearanceStream>&
states)
const;
154 void ClearAppearances();
157 PdfObject* GetAppearanceDictionaryObject();
158 const PdfObject* GetAppearanceDictionaryObject()
const;
168 Rect GetRect()
const;
172 void SetRect(
const Rect& rect);
174 Corners GetRectRaw()
const;
176 void SetRectRaw(
const Corners& rect);
180 void SetFlags(PdfAnnotationFlags flags);
187 PdfAnnotationFlags GetFlags()
const;
193 void SetBorderStyle(
double hCorner,
double vCorner,
double width);
200 void SetBorderStyle(
double hCorner,
double vCorner,
double width,
const PdfArray& strokeStyle);
206 void SetTitle(nullable<const PdfString&> title);
213 nullable<const PdfString&> GetTitle()
const;
220 void SetContents(nullable<const PdfString&> contents);
227 nullable<const PdfString&> GetContents()
const;
234 PdfColor GetColor()
const;
239 void SetColor(nullable<const PdfColor&> color);
250 inline const PdfPage* GetPage()
const {
return m_Page; }
251 PdfPage& MustGetPage();
252 const PdfPage& MustGetPage()
const;
255 template <
typename TAnnot>
256 static constexpr PdfAnnotationType GetAnnotationType();
258 static std::unique_ptr<PdfAnnotation> Create(PdfPage& page, PdfAnnotationType annotType,
const Rect& rect);
260 void SetPage(PdfPage& page) { m_Page = &page; }
263 void setAppearanceStream(PdfXObject& xobj, PdfSetAppearanceFlags flags, PdfAppearanceType appearance,
const PdfName& state);
264 static bool tryCreateFromObject(
const PdfObject& obj, PdfAnnotationType targetType, PdfAnnotation*& xobj);
266 PdfObject* getAppearanceStream(PdfAppearanceType appearance,
const std::string_view& state)
const;
267 PdfDictionary* getAppearanceDictionary()
const;
274template<
typename TAnnotation>
275bool PdfAnnotation::TryCreateFromObject(PdfObject& obj, std::unique_ptr<TAnnotation>& xobj)
277 PdfAnnotation* xobj_;
278 if (!tryCreateFromObject(obj, GetAnnotationType<TAnnotation>(), xobj_))
281 xobj.reset((TAnnotation*)xobj_);
285template<
typename TAnnotation>
286bool PdfAnnotation::TryCreateFromObject(
const PdfObject& obj, std::unique_ptr<const TAnnotation>& xobj)
288 PdfAnnotation* xobj_;
289 if (!tryCreateFromObject(obj, GetAnnotationType<TAnnotation>(), xobj_))
292 xobj.reset((
const TAnnotation*)xobj_);
296template<
typename TAnnot>
299 if (std::is_same_v<TAnnot, PdfAnnotationText>)
300 return PdfAnnotationType::Text;
301 else if (std::is_same_v<TAnnot, PdfAnnotationLink>)
302 return PdfAnnotationType::Link;
303 else if (std::is_same_v<TAnnot, PdfAnnotationFreeText>)
304 return PdfAnnotationType::FreeText;
305 else if (std::is_same_v<TAnnot, PdfAnnotationLine>)
306 return PdfAnnotationType::Line;
307 else if (std::is_same_v<TAnnot, PdfAnnotationSquare>)
308 return PdfAnnotationType::Square;
309 else if (std::is_same_v<TAnnot, PdfAnnotationCircle>)
310 return PdfAnnotationType::Circle;
311 else if (std::is_same_v<TAnnot, PdfAnnotationPolygon>)
312 return PdfAnnotationType::Polygon;
313 else if (std::is_same_v<TAnnot, PdfAnnotationPolyLine>)
314 return PdfAnnotationType::PolyLine;
315 else if (std::is_same_v<TAnnot, PdfAnnotationHighlight>)
316 return PdfAnnotationType::Highlight;
317 else if (std::is_same_v<TAnnot, PdfAnnotationUnderline>)
318 return PdfAnnotationType::Underline;
319 else if (std::is_same_v<TAnnot, PdfAnnotationSquiggly>)
320 return PdfAnnotationType::Squiggly;
321 else if (std::is_same_v<TAnnot, PdfAnnotationStrikeOut>)
322 return PdfAnnotationType::StrikeOut;
323 else if (std::is_same_v<TAnnot, PdfAnnotationStamp>)
324 return PdfAnnotationType::Stamp;
325 else if (std::is_same_v<TAnnot, PdfAnnotationCaret>)
326 return PdfAnnotationType::Caret;
327 else if (std::is_same_v<TAnnot, PdfAnnotationInk>)
328 return PdfAnnotationType::Ink;
329 else if (std::is_same_v<TAnnot, PdfAnnotationPopup>)
330 return PdfAnnotationType::Popup;
331 else if (std::is_same_v<TAnnot, PdfAnnotationFileAttachment>)
332 return PdfAnnotationType::FileAttachement;
333 else if (std::is_same_v<TAnnot, PdfAnnotationSound>)
334 return PdfAnnotationType::Sound;
335 else if (std::is_same_v<TAnnot, PdfAnnotationMovie>)
336 return PdfAnnotationType::Movie;
337 else if (std::is_same_v<TAnnot, PdfAnnotationWidget>)
338 return PdfAnnotationType::Widget;
339 else if (std::is_same_v<TAnnot, PdfAnnotationScreen>)
340 return PdfAnnotationType::Screen;
341 else if (std::is_same_v<TAnnot, PdfAnnotationPrinterMark>)
342 return PdfAnnotationType::PrinterMark;
343 else if (std::is_same_v<TAnnot, PdfAnnotationTrapNet>)
344 return PdfAnnotationType::TrapNet;
345 else if (std::is_same_v<TAnnot, PdfAnnotationWatermark>)
346 return PdfAnnotationType::Watermark;
347 else if (std::is_same_v<TAnnot, PdfAnnotationModel3D>)
348 return PdfAnnotationType::Model3D;
349 else if (std::is_same_v<TAnnot, PdfAnnotationRichMedia>)
350 return PdfAnnotationType::RichMedia;
351 else if (std::is_same_v<TAnnot, PdfAnnotationWebMedia>)
352 return PdfAnnotationType::WebMedia;
353 else if (std::is_same_v<TAnnot, PdfAnnotationRedact>)
354 return PdfAnnotationType::Redact;
355 else if (std::is_same_v<TAnnot, PdfAnnotationProjection>)
356 return PdfAnnotationType::Projection;
358 return PdfAnnotationType::Unknown;
An annotation to a PdfPage To create an annotation use PdfPage::CreateAnnotation.
Definition PdfAnnotation.h:68
PdfAnnotationType GetType() const
Get the type of this annotation.
Definition PdfAnnotation.h:244
PdfObject * GetAppearanceStream(PdfAppearanceType appearance=PdfAppearanceType::Normal, const std::string_view &state={ })
PdfPage * GetPage()
Get the page of this PdfField.
Definition PdfAnnotation.h:249
This class represents a PdfName.
Definition PdfName.h:21
This class represents a PDF indirect Object in memory.
Definition PdfObject.h:31
PdfPage is one page in the pdf document.
Definition PdfPage.h:133
A XObject is a content stream with several drawing commands and data which can be used throughout a P...
Definition PdfXObject.h:28
An normalized rectangle defined by position (left-bottom) and size.
Definition Rect.h:17
Convenient type for char array storage and/or buffer with std::string compatibility.
Definition basetypes.h:30
All classes, functions, types and enums of PoDoFo are members of these namespace.
Definition basetypes.h:13
PdfAnnotationType
The type of the annotation.
Definition PdfDeclarations.h:557
PdfSetAppearanceFlags
Definition PdfAnnotation.h:55
@ Raw
Insert the appearance stream without handling page rotations.
@ SkipSelectedState
Skip setting the selected state.
@ InplaceRotation
Try skip inserting a XObject trampoline for the appearance stream in case of page rotations.
@ None
Do not add a default appearance.
PdfAppearanceType
Type of the annotation appearance.
Definition PdfDeclarations.h:646
A qualified appearance stream, with type and state name.
Definition PdfAnnotation.h:48