|
#include <Annot.h>
Public Types | |
| enum | Type { e_Text, e_Link, e_FreeText, e_Line, e_Square, e_Circle, e_Polygon, e_Polyline, e_Highlight, e_Underline, e_Squiggly, e_StrikeOut, e_Stamp, e_Caret, e_Ink, e_Popup, e_FileAttachment, e_Sound, e_Movie, e_Widget, e_Screen, e_PrinterMark, e_TrapNet, e_Watermark, e_3D, e_Unknown } |
| PDF supports the standard annotation types listed in the following enumeration (plug-in extensions may add new annotation types):. More... | |
| enum | Flag { e_invisible, e_hidden, e_print, e_no_zoom, e_no_rotate, e_no_view, e_read_only, e_locked, e_toggle_no_view } |
| Flags specifying various characteristics of the annotation. More... | |
| enum | AnnotationState { e_normal, e_rollover, e_down } |
| An annotation can define as many as three separate appearances:. More... | |
Public Member Functions | |
| Annot (SDF::Obj d=0) | |
| Create an annotation and initialize it using given Cos/SDF object. | |
| Annot (const Annot &d) | |
| Copy constructor. | |
| Annot & | operator= (const Annot &d) |
| Assignment operator. | |
| bool | operator== (const Annot &d) |
| Compares two annotations for equality. | |
| bool | IsValid () const |
| |
| Type | GetType () const |
| |
| SDF::Obj | GetSDFObj () const |
| |
| Rect | GetRect () const |
| |
| void | SetRect (const Rect &pos) |
| Sets the size and location of an annotation on its page. | |
| bool | GetFlag (Flag flag) const |
| |
| void | SetFlag (Flag flag, bool value) |
| Sets the value of given AnnotFlag. | |
| Date | GetDate () const |
| Gets an annotation's date. | |
| void | SetDate (const Date &date) |
| Sets an annotation's date. | |
| SDF::Obj | GetUniqueID () const |
| |
| void | SetUniqueID (const char *id, int id_buf_sz=0) |
| Sets the unique identifier for this annotation. | |
| ColorPt | GetColor () const |
| Gets a note or link annotation's color. | |
| void | SetColor (const ColorPt &rgb) |
| Sets a note or link annotation's color. | |
| BorderStyle | GetBorderStyle () const |
| Gets the border style for the annotation. | |
| void | SetBorderStyle (const BorderStyle &bs) |
| Sets the border style for the annotation. | |
| SDF::Obj | GetAppearance (AnnotationState annot_state=e_normal, const char *app_state=0) |
| Gets the annotation’s appearance for the given combination of annotation and appearance states. | |
| void | SetAppearance (SDF::Obj app_stream, AnnotationState annot_state=e_normal, const char *app_state=0) |
| Sets the annotation’s appearance for the given combination of annotation and appearance states. | |
| class Action | GetLinkAction () const |
| Gets a link annotation's action. | |
| void | SetLinkAction (const class Action &action) |
| Sets a link annotation's action. | |
| void | RemoveLinkAction () |
| Removes a link annotation's action. | |
| void | SetTextContents (const UString &contents) |
| Sets the text of a text annotation. | |
| SDF::Obj | GetTextContents () const |
| Gets the text of a text annotation. | |
| const char * | GetTextIcon () const |
| Gets the name of an icon to be used in displaying the annotation. | |
| void | SetTextIcon (const char *icon_name) |
| Sets the name of an icon to be used in displaying the annotation. | |
| bool | IsTextAnnotOpen () const |
| Tests whether a text annotation is open. | |
| void | SetTextAnnotOpen (bool is_open) |
| Opens or closes a text annotation. | |
| const char * | GetStampName () const |
| Gets the name of the stamp to be used in displaying the annotation. | |
| void | SetStampName (const char *name) |
| Sets the name of the stamp to be used in displaying the annotation. | |
| class Field | GetWidgetField () const |
| |
| FileSpec | GetFileAttachment () const |
| Gets the file specification associated with this File Attachment annotation. | |
| void | SetFileAttachment (const FileSpec &file) |
| Sets the file specification for this File Attachment annotation. | |
| bool | FileAttachmentExport (const UString &save_as="") const |
| The function saves the data referenced by this File Attachment to an external file. | |
Static Public Member Functions | |
| static Annot | Create (SDF::SDFDoc &doc, Type type, const Rect &pos) |
| Creates a new annotation of a given type, in the specified document. | |
| static Annot | CreateLink (SDF::SDFDoc &doc, const Rect &pos, const class Action &action) |
| Creates a new Link annotation. | |
| static Annot | CreateText (SDF::SDFDoc &doc, const Rect &pos, const UString &contents) |
| Creates a new Text annotation. | |
| static Annot | CreateStamp (SDF::SDFDoc &doc, const Rect &pos, const char *name="Draft") |
| Creates a new rubber stamp annotation. | |
| static Annot | CreateWidget (SDF::SDFDoc &doc, const Rect &pos, class Field field) |
| Create a widget annotation given a Field and a rectangle specifying the location where the widget should be positioned. | |
| static Annot | CreateFileAttachment (SDF::SDFDoc &doc, const Rect &pos, const char *path, const char *icon_name="PushPin") |
| Create a file attachment annotation. | |
Classes | |
| class | BorderStyle |
| BorderStyle structure specifies the characteristics of the annotation’s border. More... | |
PDF includes a wide variety of standard annotation types. An annotation associates an object such as a widget, note, or movie with a location on a page of a PDF document, or provides a means of interacting with the user via the mouse and keyboard.
Just like many other classes in PDFNet (e.g. Element, ColorSpace, Font, etc), Annot class follows the composite design pattern. This means that all annotations are accessed through the same interface, but depending on the annotation type (that can be obtained using GetType()), only methods related to that type can be called. For example, if GetType() returns e_Link, it is illegal to call a method specific to another annotation type (i.e. a call to SetTextIcon() may throw an Exception)
For more details on PDF annotations please refer to section 8.4 in the PDF Reference Manual.
PDF supports the standard annotation types listed in the following enumeration (plug-in extensions may add new annotation types):.
Flags specifying various characteristics of the annotation.
An annotation can define as many as three separate appearances:.
| pdftron::PDF::Annot::Annot | ( | SDF::Obj | d = 0 |
) |
Create an annotation and initialize it using given Cos/SDF object.
| pdftron::PDF::Annot::Annot | ( | const Annot & | d | ) |
Copy constructor.
| static Annot pdftron::PDF::Annot::Create | ( | SDF::SDFDoc & | doc, | |
| Type | type, | |||
| const Rect & | pos | |||
| ) | [static] |
Creates a new annotation of a given type, in the specified document.
Because the newly created annotation does not contain any properties specific to a given annotation type, it is faster to create an annotation using type specific Annot.Create method.
| doc | A document to which the annotation is added. | |
| type | Subtype of annotation to create. | |
| pos | A rectangle specifying the annotation's bounds, specified in user space coordinates. |
| static Annot pdftron::PDF::Annot::CreateLink | ( | SDF::SDFDoc & | doc, | |
| const Rect & | pos, | |||
| const class Action & | action | |||
| ) | [static] |
Creates a new Link annotation.
| doc | A document to which the annotation is added. | |
| pos | A rectangle specifying the annotation's bounds, specified in user space coordinates. | |
| action | Action for the link annotation. |
| static Annot pdftron::PDF::Annot::CreateText | ( | SDF::SDFDoc & | doc, | |
| const Rect & | pos, | |||
| const UString & | contents | |||
| ) | [static] |
Creates a new Text annotation.
A text annotation represents a 'sticky note' attached to a point in the PDF document. When closed, the annotation appears as an icon; when open, it displays a pop-up window containing the text of the note in a font and size chosen by the viewer application. Text annotations do not scale and rotate with the page.
| doc | A document to which the annotation is added. | |
| pos | A rectangle specifying the annotation's bounds, specified in user space coordinates. | |
| contents | - a buffer containing new text contents represented in PDFDocEncoding or Unicode. | |
| contents_sz | - the size of 'contents_sz' buffer, or 0 if the string is NULL terminated. |
| static Annot pdftron::PDF::Annot::CreateStamp | ( | SDF::SDFDoc & | doc, | |
| const Rect & | pos, | |||
| const char * | name = "Draft" | |||
| ) | [static] |
Creates a new rubber stamp annotation.
A rubber stamp annotation displays text or graphics intended to look as if they were stamped on the page with a rubber stamp. When opened, it displays a pop-up window containing the text of the associated note.
| doc | A document to which the annotation is added. | |
| pos | A rectangle specifying the annotation's bounds, specified in user space coordinates. | |
| name | The name of an icon to be used in displaying the annotation. PDF Viewer applications should provide predefined icon appearances for at least the following standard names: Approved, AsIs, Confidential, Departmental, Draft, Experimental, Expired, Final, ForComment, ForPublicRelease, NotApproved, NotForPublicRelease, Sold, TopSecret. Additional names may be supported as well. Default value: Draft. |
| static Annot pdftron::PDF::Annot::CreateWidget | ( | SDF::SDFDoc & | doc, | |
| const Rect & | pos, | |||
| class Field | field | |||
| ) | [static] |
Create a widget annotation given a Field and a rectangle specifying the location where the widget should be positioned.
Interactive forms (see Section 8.6, 'Interactive Forms' in PDF Reference Manual) use widget annotations to represent the appearance of fields and to manage user interactions.
| doc | A document to which the annotation is added. | |
| pos | A rectangle specifying the annotation's bounds, specified in user space coordinates. | |
| field | A form Filed used to construct the Widget annotation. |
| static Annot pdftron::PDF::Annot::CreateFileAttachment | ( | SDF::SDFDoc & | doc, | |
| const Rect & | pos, | |||
| const char * | path, | |||
| const char * | icon_name = "PushPin" | |||
| ) | [static] |
Create a file attachment annotation.
A file attachment annotation contains a reference to a file, which typically is embedded in the PDF file.
| doc | A document to which the annotation is added. | |
| pos | A rectangle specifying the annotation's bounds, specified in user space coordinates. | |
| icon_name | The name of an icon to be used in displaying the annotation. PDF Viewer applications should provide predefined icon appearances for at least the following standard names: Graph PushPin Paperclip Tag. Additional names may be supported as well. Default value: PushPin. |
| bool pdftron::PDF::Annot::operator== | ( | const Annot & | d | ) |
Compares two annotations for equality.
The comparison will return true only if both annotations share the same underlying SDF/Cos object.
| bool pdftron::PDF::Annot::IsValid | ( | ) | const |
If the function returns false the underlying SDF/Cos object is null or is not valid and the annotation object should be treated as a null object.
| Type pdftron::PDF::Annot::GetType | ( | ) | const |
| SDF::Obj pdftron::PDF::Annot::GetSDFObj | ( | ) | const |
| Rect pdftron::PDF::Annot::GetRect | ( | ) | const |
The meaning of the rectangle depends on the annotation type. For Link and Stamp annotations, the rectangle specifies the area containing the hyperlink area or stamp. For Note annotations, the rectangle is describing the popup window when it's opened. When it's closed, the icon is positioned at lower left corner.
| void pdftron::PDF::Annot::SetRect | ( | const Rect & | pos | ) |
Sets the size and location of an annotation on its page.
| pos | Annotation’s bounding rectangle, specified in user space coordinates. |
| bool pdftron::PDF::Annot::GetFlag | ( | Flag | flag | ) | const |
| flag | the Flag property to query. |
| void pdftron::PDF::Annot::SetFlag | ( | Flag | flag, | |
| bool | value | |||
| ) |
Sets the value of given AnnotFlag.
| flag | the Flag property to modifiy. | |
| value | The new value for the property. |
| Date pdftron::PDF::Annot::GetDate | ( | ) | const |
Gets an annotation's date.
| void pdftron::PDF::Annot::SetDate | ( | const Date & | date | ) |
Sets an annotation's date.
| SDF::Obj pdftron::PDF::Annot::GetUniqueID | ( | ) | const |
The returned value is a String object and is the value of the "NM" field, which was added as an optional attribute in PDF 1.4.
| void pdftron::PDF::Annot::SetUniqueID | ( | const char * | id, | |
| int | id_buf_sz = 0 | |||
| ) |
Sets the unique identifier for this annotation.
| id | - a buffer containing a unique identifier for this annotation. | |
| id_buf_sz | - the size of 'id' buffer, or 0 if the string is NULL terminated. |
| ColorPt pdftron::PDF::Annot::GetColor | ( | ) | const |
Gets a note or link annotation's color.
| void pdftron::PDF::Annot::SetColor | ( | const ColorPt & | rgb | ) |
Sets a note or link annotation's color.
| rgb | - A color point in RGB color space representing the color for this annotation. RGB components are three numbers in the range 0.0 to 1.0. Depending on the annotation's type this color is used for the following purposes:
|
| BorderStyle pdftron::PDF::Annot::GetBorderStyle | ( | ) | const |
Gets the border style for the annotation.
Typically used for Link annotations.
| void pdftron::PDF::Annot::SetBorderStyle | ( | const BorderStyle & | bs | ) |
Sets the border style for the annotation.
Typically used for Link annotations.
| new | border style for this annotation. |
| SDF::Obj pdftron::PDF::Annot::GetAppearance | ( | AnnotationState | annot_state = e_normal, |
|
| const char * | app_state = 0 | |||
| ) |
Gets the annotation’s appearance for the given combination of annotation and appearance states.
| annot_state | the annotation’s appearance state, which selects the applicable appearance stream from the appearance sub-dictionary. An annotation can define as many as three separate appearances: The normal, rollover, and down appearance. | |
| app_state | is an optional parameter specifying the appearance state to look for (e.g. "Off", "On", etc). If appearance_state is NULL, the choice between different appearance states is determined by the AS (Appearance State) entry in the annotation dictionary. |
| void pdftron::PDF::Annot::SetAppearance | ( | SDF::Obj | app_stream, | |
| AnnotationState | annot_state = e_normal, |
|||
| const char * | app_state = 0 | |||
| ) |
Sets the annotation’s appearance for the given combination of annotation and appearance states.
| app_stream | a content stream defining the new appearance. | |
| annot_state | the annotation’s appearance state, which selects the applicable appearance stream from the appearance sub-dictionary. An annotation can define as many as three separate appearances: The normal, rollover, and down appearance. | |
| app_state | is an optional parameter specifying the appearance state (e.g. "Off", "On", etc) under which the new appearance should be stored. If appearance_state is NULL, the annotation will have only one annotaion state. |
| class Action pdftron::PDF::Annot::GetLinkAction | ( | ) | const |
Gets a link annotation's action.
| void pdftron::PDF::Annot::SetLinkAction | ( | const class Action & | action | ) |
Sets a link annotation's action.
| action | - New action for the link annotation. |
| void pdftron::PDF::Annot::RemoveLinkAction | ( | ) |
Removes a link annotation's action.
| void pdftron::PDF::Annot::SetTextContents | ( | const UString & | contents | ) |
Sets the text of a text annotation.
| contents | - new text contents string. |
| SDF::Obj pdftron::PDF::Annot::GetTextContents | ( | ) | const |
Gets the text of a text annotation.
| const char* pdftron::PDF::Annot::GetTextIcon | ( | ) | const |
Gets the name of an icon to be used in displaying the annotation.
| void pdftron::PDF::Annot::SetTextIcon | ( | const char * | icon_name | ) |
Sets the name of an icon to be used in displaying the annotation.
| icon_name | The string representing the name of an icon to be used in displaying the annotation or NULL if the default should be used. |
| bool pdftron::PDF::Annot::IsTextAnnotOpen | ( | ) | const |
Tests whether a text annotation is open.
This method is applicable only if this is e_Text annotation.
| void pdftron::PDF::Annot::SetTextAnnotOpen | ( | bool | is_open | ) |
Opens or closes a text annotation.
| is_open | true if the annotation is opened, false if the annotation is closed. |
See IsTextAnnotOpen() for details.
| const char* pdftron::PDF::Annot::GetStampName | ( | ) | const |
Gets the name of the stamp to be used in displaying the annotation.
See SetStampName() for details.
| void pdftron::PDF::Annot::SetStampName | ( | const char * | name | ) |
Sets the name of the stamp to be used in displaying the annotation.
| name | The string representing the stamp name of an icon to be used in displaying the annotation. PDF Viewer applications should provide predefined icon appearances for at least the following standard names: Approved, AsIs, Confidential, Departmental, Draft, Experimental, Expired, Final, ForComment, ForPublicRelease, NotApproved, NotForPublicRelease, Sold, TopSecret. Additional names may be supported as well. |
| class Field pdftron::PDF::Annot::GetWidgetField | ( | ) | const |
Because in some documents a Widget may not be attached to a field make sure that the returned field is valid (i.e. Field.IsValid()).
| FileSpec pdftron::PDF::Annot::GetFileAttachment | ( | ) | const |
Gets the file specification associated with this File Attachment annotation.
| void pdftron::PDF::Annot::SetFileAttachment | ( | const FileSpec & | file | ) |
Sets the file specification for this File Attachment annotation.
| file | The new file specification for the annotation. |
| bool pdftron::PDF::Annot::FileAttachmentExport | ( | const UString & | save_as = "" |
) | const |
The function saves the data referenced by this File Attachment to an external file.
If the file is embedded, the function saves the embedded file. If the file is not embedded, the function will copy the external file. If the file is not embedded and the external file can't be found, the function returns false.
| save_as | An optional parameter indicating the filepath and filename where the data should be saved. If this parameter is not specified the function will attempt to save the file using FileSpec.GetFilePath(). |