Foxit PDF SDK
fsdk.Annot Class Reference

Public Member Functions

def GetAppearanceStream (type, appearance_state)
 Get annotation's appearance stream with specified type and state.
More...
 
def GetBorderColor ()
 Get border color.
More...
 
def GetBorderInfo ()
 Get border information.
More...
 
def GetContent ()
 Get content.
More...
 
def GetDeviceRect (matrix)
 Get annotation rectangle in device coordinate system.
More...
 
def GetDict ()
 Get annotation's dictionary object.
More...
 
def GetDisplayMatrix (page_display_matrix)
 Get the display matrix, from [PDF coordinate system] () to targeted device coordinate system.
More...
 
def GetFlags ()
 Get annotation flags.
More...
 
def GetIndex ()
 Get the index of current annotation in the page which current annotation belongs to.
More...
 
def GetModifiedDateTime ()
 Get last modified date time.
More...
 
def GetOptionalContent ()
 Get the PDF dictionary of annotation's optional content.
More...
 
def GetPage ()
 Get the related PDF page.
More...
 
def GetRect ()
 Get rectangle, in [PDF coordinate system] ().
More...
 
def GetType ()
 Get actual annotation type of current annotation.
More...
 
def GetUniqueID ()
 Get unique ID.
More...
 
def HasProperty (property)
 Whether current annotation has the specified annotation's property.
More...
 
def IsEmpty ()
 Check whether current object is empty or not.
More...
 
def IsMarkup ()
 Check if current annotation is a markup annotation.
More...
 
def Move (rect)
 Move current annotation to a new position, specified by a new rectangle in [PDF coordinate system] ().
More...
 
def Move (rect, is_reset_appearance)
 Move current annotation to a new position, specified by a new rectangle in [PDF coordinate system] ().
More...
 
def RemoveProperty (property)
 Remove a specified annotation's property.
More...
 
def ResetAppearanceStream (a, interface)
 Reset appearance stream.
More...
 
def SetBorderColor (color)
 Set border color.
More...
 
def SetBorderInfo (border)
 Set border information.
More...
 
def SetContent (content)
 Set content.
More...
 
def SetFlags (flags)
 Set annotation flags.
More...
 
def SetModifiedDateTime (date_time)
 Set last modified date time.
More...
 
def SetUniqueID (unique_id)
 Set unique ID.
More...
 

Detailed Description

An annotation associates an object such as a note, sound, or movie with a location on a page of a PDF document, or provides a way to interact with the user by means of the mouse and keyboard. PDF includes a wide variety of standard annotation types.
Class Annot is the base class for all kinds of PDF annotations. It offers the base functions to get/set annotation's common properties, to move an annotation or reset appearance stream of an annotation. For concrete annotation types, please refer to derived classes. To get the count of annotations or get/add/remove an annotation, please refer to class pdf::PDFPage.
This class object can also be used to construct objects of other classes in order to do some more operation in annotation or access specified information of annotation:

  • To access additional actions, please construct an fsdk.AdditionalAction object with annotation object. Only a few types of annotations may have additional action. For more details, please refer to class fsdk.AdditionalAction .
  • To search text in annotation, please construct a fsdk.TextSearch object with annotation object. The searching can only support some types of annotations. For more details, please refer to class fsdk.TextSearch .


Note
Currently, following kind of functions only support note, highlight, underline, strikeout, squiggly, link, square, circle, free text, stamp, caret, ink, line, polygon, polyline, file attachment, pop-up, widget, screen, PSInk, redact annotations:
See also
fsdk.PDFPage
fsdk.AdditionalAction
fsdk.TextSearch

Member Function Documentation

◆ GetAppearanceStream()

def fsdk.Annot.GetAppearanceStream (   type,
  appearance_state 
)

Get annotation's appearance stream with specified type and state.

For more details, please refer to "AP" and "AS" entries in "TABLE 8.15 Entries common to all annotation dictionaries" in <PDF reference 1.7>.

Parameters
[in]typeType of annotation's appearance. Please refer to values starting from fsdk.AnnotE_AppearanceTypeNormal and this should be one of these values.
[in]appearance_stateAnnotation's appearance state, which is used to select the applicable appearance stream from an appearance sub- dictionary. If this is an empty string, Foxit PDF SDK will choose the appearance state specified by the "AS" (Appearance State) entry in the annotation dictionary.
Returns
The specified annotation's appearance stream. If there is no entry which related to appearance or any error occurs, this function will return null.

◆ GetBorderColor()

def fsdk.Annot.GetBorderColor ( )

Get border color.

This property has effect on annotation's appearance.

Returns
The border color. Format: 0xRRGGBB. If no border color can be found, 0x000000 will be returned.

◆ GetBorderInfo()

def fsdk.Annot.GetBorderInfo ( )

Get border information.

This property has effect on annotation's appearance. For an annotation which does not have border information, the default border information will be returned:
border width = 1, border style = fsdk.BorderInfoE_Solid , border cloud intensity = 0, border dash phase = 0, border dashes array is an empty array. Attention: among supported annotation types (please refer to "Note" comment part of class Annot ), this property will not have effect on appearance of these annotations: note, highlight, underline, strikeout, squiggly, stamp, caret, popup, file attachment, PSInk, redact. For ink annotation, only border width will have effect on ink annotation's appearance.

Returns
A border information object that received the border information. If not find any border information, the default border information will be returned as described in "Details" part.

◆ GetContent()

def fsdk.Annot.GetContent ( )

Get content.

Returns
Content string.

◆ GetDeviceRect()

def fsdk.Annot.GetDeviceRect (   matrix)

Get annotation rectangle in device coordinate system.

This is a useful function to get the device rectangle of an annotation, but not support pop-up annotation.
For the rectangle conversion, the result rectangle is always "normalized", which is using device coordinate system: left is always smaller than right, and top is always smaller than bottom.

Parameters
[in]matrixA matrix used to transform from [PDF coordinate system] () to device coordinate system. Usually, this is returned by function fsdk.PDFPage.GetDisplayMatrix and also used for rendering.
Returns
The annotation rectangle in device coordinate system. If there is no rectangle information, a RectI object with all 0 values would be returned.

◆ GetDict()

def fsdk.Annot.GetDict ( )

Get annotation's dictionary object.

Returns
Annotation's dictionary. If there is any error, this function will return null.

◆ GetDisplayMatrix()

def fsdk.Annot.GetDisplayMatrix (   page_display_matrix)

Get the display matrix, from [PDF coordinate system] () to targeted device coordinate system.

Display matrix of current annotation can be used with annotation's rectangle to calculate the real area of annotation in target device coordinate system.

Parameters
[in]page_display_matrixThe transformation matrix. Usually this is returned by function fsdk.PDFPage.GetDisplayMatrix .
Returns
The display matrix of current annotation.

◆ GetFlags()

def fsdk.Annot.GetFlags ( )

Get annotation flags.

Returns
The annotation flags. Please refer to values starting from fsdk.AnnotE_FlagInvisible and this would be one or a combination of these values. 0 means no annotation flag.

◆ GetIndex()

def fsdk.Annot.GetIndex ( )

Get the index of current annotation in the page which current annotation belongs to.

Returns
The index value, starting from 0.

◆ GetModifiedDateTime()

def fsdk.Annot.GetModifiedDateTime ( )

Get last modified date time.

Returns
A date and time object that receives the last modified date time. If there is no modified date time information, a date and time object with all 0 values would be returned.

◆ GetOptionalContent()

def fsdk.Annot.GetOptionalContent ( )

Get the PDF dictionary of annotation's optional content.

Returns
The PDF dictionary of annotation's optional content. If there is no "OC" entry or any error occurs, this function will return null.

◆ GetPage()

def fsdk.Annot.GetPage ( )

Get the related PDF page.

Returns
A PDF page object which is the related PDF page.

◆ GetRect()

def fsdk.Annot.GetRect ( )

Get rectangle, in [PDF coordinate system] ().

Returns
The annotation rectangle. If there is no rectangle information, a RectF object with all 0 values would be returned.

◆ GetType()

def fsdk.Annot.GetType ( )

Get actual annotation type of current annotation.

Returns
Annotation type. Please refer to values starting from fsdk.AnnotE_Note and this would be one of these values.

◆ GetUniqueID()

def fsdk.Annot.GetUniqueID ( )

Get unique ID.

Returns
Unique ID string.

◆ HasProperty()

def fsdk.Annot.HasProperty (   property)

Whether current annotation has the specified annotation's property.

Parameters
[in]propertyProperty name. Please refer to values starting from fsdk.AnnotE_PropertyModifiedDate and this should be one of these values.
Returns
true means current annotation has the specified property, while false means current annotation does not have the specified property.

◆ IsEmpty()

def fsdk.Annot.IsEmpty ( )

Check whether current object is empty or not.

When the current object is empty, that means current object is useless.

Returns
true means current object is empty, while false means not.

◆ IsMarkup()

def fsdk.Annot.IsMarkup ( )

Check if current annotation is a markup annotation.

Returns
true means current annotation is a markup annotation, while false means current annotation is not a markup annotation.

◆ Move() [1/2]

def fsdk.Annot.Move (   rect)

Move current annotation to a new position, specified by a new rectangle in [PDF coordinate system] ().

Parameters
[in]rectNew rectangle to specify the new position where current annotation is to be moved to. It should be valid in [PDF coordinate system] ().
Returns
true means success, while false means failure.

◆ Move() [2/2]

def fsdk.Annot.Move (   rect,
  is_reset_appearance 
)

Move current annotation to a new position, specified by a new rectangle in [PDF coordinate system] ().

Parameters
[in]rectNew rectangle to specify the new position where current annotation is to be moved to. It should be valid in [PDF coordinate system] ().
[in]is_reset_appearanceA boolean value specifies whether to reset annotation's appearance after moving.
Returns
true means success, while false means failure.

◆ RemoveProperty()

def fsdk.Annot.RemoveProperty (   property)

Remove a specified annotation's property.

This function can be used to remove some optional properties of an annotation. When appearance related property is removed successfully, such as fsdk.AnnotE_PropertyBorderColor and fsdk.AnnotE_PropertyFillColor , user should call function fsdk.Annot.ResetAppearanceStream to make effect on annotation's appearance.

Parameters
[in]propertyProperty name. Please refer to values starting from fsdk.AnnotE_PropertyModifiedDate and this should be one of these values.
Returns
true means remove the specified property successfully, or current annotation supports the property but does not have the property.
false means current annotation does not support to have the specified property, or current annotation cannot be removed specified property.

◆ ResetAppearanceStream()

def fsdk.Annot.ResetAppearanceStream (   a,
  interface 
)

Reset appearance stream.

Annotation's appearance is stored as stream in PDF document. Any appearance-related property can be changed through the corresponding setting functions. For this change to take effect, this function should be called to update the annotation's appearance.
Please check "Note" part in the comment of class Annot to see which types of annotations can be reset appearance by current function and also check comment in classes of these annotations to see if any property is required before resetting appearance stream.

Returns
true means success, while false means failure.

Annotation's appearance is stored as stream in PDF document. Any appearance-related property can be changed through the corresponding setting functions. For this change to take effect, this function should be called to update the annotation's appearance.
Please check "Note" part in the comment of class Annot to see which types of annotations can be reset appearance by current function and also check comment in classes of these annotations to see if any property is required before resetting appearance stream.

Parameters
[in]is_generate_new_appearance_objtrue means to generate a new appearance object to reset the appearance of the current annotation, while false means to reset the appearance of annotations that share this appearance stream. The parameter has only effect on widget annotation's appearance.
Returns
true means success, while false means failure.

◆ SetBorderColor()

def fsdk.Annot.SetBorderColor (   color)

Set border color.

This property has effect on annotation's appearance. If user wants the new border color has effect on annotation's appearance, please call function fsdk.Annot.ResetAppearanceStream after setting the new border color.

Parameters
[in]colorNew border color to be set. Format: 0xRRGGBB.
Returns
None.

◆ SetBorderInfo()

def fsdk.Annot.SetBorderInfo (   border)

Set border information.

This property has effect on annotation's appearance. If user wants the new border information has effect on annotation's appearance, please call function fsdk.Annot.ResetAppearanceStream after setting the new border information.
Attention: among supported annotation types (please refer to "Note" comment part of class Annot ), this property will not have effect on appearance of these annotations: note, highlight, underline, strikeout, squiggly, stamp, caret, popup, file attachment, PSInk, redact. For ink annotation, only border width will have effect on ink annotation's appearance.

Parameters
[in]borderNew border information to be set. It should be a valid border information object. If any value of parameter border is invalid, this function will fail to set new border information to current annotation.
Returns
None.

◆ SetContent()

def fsdk.Annot.SetContent (   content)

Set content.

For free text annotation and line annotation (which has enabled caption), they would show content in their appearance. So for these kinds of annotations, this property would have effect on annotation's appearance. If user wants the effect to be shown in the appearance of these kind of annotations, please call function fsdk.Annot.ResetAppearanceStream after setting new content.

Parameters
[in]contentNew content string to be set.
Returns
None.

◆ SetFlags()

def fsdk.Annot.SetFlags (   flags)

Set annotation flags.

Parameters
[in]flagsThe annotation flags. It could be 0, or one or a combination of values starting from fsdk.AnnotE_FlagInvisible .
Returns
None.

◆ SetModifiedDateTime()

def fsdk.Annot.SetModifiedDateTime (   date_time)

Set last modified date time.

Parameters
[in]date_timeThe data time to be set. It should contain valid date time data.
Returns
None.

◆ SetUniqueID()

def fsdk.Annot.SetUniqueID (   unique_id)

Set unique ID.

Parameters
[in]unique_idNew unique ID string to be set.
Returns
None.