org.pdfbox.pdmodel.interactive.annotation
Class PDAnnotation

java.lang.Object
  extended byorg.pdfbox.pdmodel.interactive.annotation.PDAnnotation
All Implemented Interfaces:
COSObjectable
Direct Known Subclasses:
PDAnnotationFileAttachment, PDAnnotationLink, PDAnnotationMarkup, PDAnnotationPopup, PDAnnotationUnknown, PDAnnotationWidget

public abstract class PDAnnotation
extends Object
implements COSObjectable

This class represents a PDF annotation.

Version:
$Revision: 1.14 $
Author:
Ben Litchfield

Field Summary
static int FLAG_HIDDEN
          An annotation flag.
static int FLAG_INVISIBLE
          An annotation flag.
static int FLAG_LOCKED
          An annotation flag.
static int FLAG_NO_ROTATE
          An annotation flag.
static int FLAG_NO_VIEW
          An annotation flag.
static int FLAG_NO_ZOOM
          An annotation flag.
static int FLAG_PRINTED
          An annotation flag.
static int FLAG_READ_ONLY
          An annotation flag.
static int FLAG_TOGGLE_NO_VIEW
          An annotation flag.
 
Constructor Summary
PDAnnotation()
          Constructor.
PDAnnotation(COSDictionary dict)
          Constructor.
 
Method Summary
static PDAnnotation createAnnotation(COSBase base)
          Create the correct annotation from the base COS object.
 PDAction getAction()
          Get the action to be performed when this annotation is to be activated.
 PDAdditionalActions getActions()
          Get the additional actions for this field.
 int getAnnotationFlags()
          This will get the flags for this field.
 String getAnnotationName()
          This will get the name, a string intended to uniquely identify each annotatoin within a page.
 PDAppearanceDictionary getAppearance()
          This will get the appearance dictionary associated with this annotation.
 String getAppearanceStream()
          This will get the name of the current appearance stream if any.
 PDBorderStyleDictionary getBoderStyle()
          This will retrieve the border style dictionary, specifying the width and dash pattern used in drawing the line.
 PDGamma getColour()
          This will retrieve the colour used in drawing various elements.
 String getContents()
          Get the "contents" of the field.
 COSBase getCOSObject()
          Interface method for COSObjectable.
 COSDictionary getDictionary()
          returns the dictionary.
 String getModifiedDate()
          This will retrieve the date and time the annotation was modified.
 PDRectangle getRectangle()
          The annotation rectangle, defining the location of the annotation on the page in default user space units.
 boolean isHidden()
          Get the hidden flag.
 boolean isInvisible()
          Get the invisible flag.
 boolean isLocked()
          Get the locked flag.
 boolean isNoRotate()
          Get the noRotate flag.
 boolean isNoView()
          Get the noView flag.
 boolean isNoZoom()
          Get the noZoom flag.
 boolean isPrinted()
          Get the printed flag.
 boolean isReadOnly()
          Get the readOnly flag.
 boolean isToggleNoView()
          Get the toggleNoView flag.
 void setAction(PDAction action)
          Set the annotation action.
 void setActions(PDAdditionalActions actions)
          Set the actions of the field.
 void setAnnotationFlags(int flags)
          This will set the flags for this field.
 void setAnnotationName(String nm)
          This will set the name, a string intended to uniquely identify each annotatoin within a page.
 void setAppearance(PDAppearanceDictionary appearance)
          This will set the appearance associated with this annotation.
 void setAppearanceStream(String as)
          This will set the annotations appearance stream name.
 void setBorderStyle(PDBorderStyleDictionary bs)
          This will set the border style dictionary, specifying the width and dash pattern used in drawing the line.
 void setColour(PDGamma c)
          This will set the colour used in drawing various elements.
 void setContents(String value)
          Set the "contents" of the field.
 void setHidden(boolean hidden)
          Set the hidden flag.
 void setInvisible(boolean invisible)
          Set the invisible flag.
 void setLocked(boolean locked)
          Set the locked flag.
 void setModifiedDate(String m)
          This will set the the date and time the annotation was modified.
 void setNoRotate(boolean noRotate)
          Set the noRotate flag.
 void setNoView(boolean noView)
          Set the noView flag.
 void setNoZoom(boolean noZoom)
          Set the noZoom flag.
 void setPrinted(boolean printed)
          Set the printed flag.
 void setReadOnly(boolean readOnly)
          Set the readOnly flag.
 void setRectangle(PDRectangle rectangle)
          This will set the rectangle for this annotation.
 void setToggleNoView(boolean toggleNoView)
          Set the toggleNoView flag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FLAG_INVISIBLE

public static final int FLAG_INVISIBLE
An annotation flag.

See Also:
Constant Field Values

FLAG_HIDDEN

public static final int FLAG_HIDDEN
An annotation flag.

See Also:
Constant Field Values

FLAG_PRINTED

public static final int FLAG_PRINTED
An annotation flag.

See Also:
Constant Field Values

FLAG_NO_ZOOM

public static final int FLAG_NO_ZOOM
An annotation flag.

See Also:
Constant Field Values

FLAG_NO_ROTATE

public static final int FLAG_NO_ROTATE
An annotation flag.

See Also:
Constant Field Values

FLAG_NO_VIEW

public static final int FLAG_NO_VIEW
An annotation flag.

See Also:
Constant Field Values

FLAG_READ_ONLY

public static final int FLAG_READ_ONLY
An annotation flag.

See Also:
Constant Field Values

FLAG_LOCKED

public static final int FLAG_LOCKED
An annotation flag.

See Also:
Constant Field Values

FLAG_TOGGLE_NO_VIEW

public static final int FLAG_TOGGLE_NO_VIEW
An annotation flag.

See Also:
Constant Field Values
Constructor Detail

PDAnnotation

public PDAnnotation()
Constructor.


PDAnnotation

public PDAnnotation(COSDictionary dict)
Constructor.

Parameters:
dict - The annotations dictionary.
Method Detail

createAnnotation

public static PDAnnotation createAnnotation(COSBase base)
                                     throws IOException
Create the correct annotation from the base COS object.

Parameters:
base - The COS object that is the annotation.
Returns:
The correctly typed annotation object.
Throws:
IOException - If there is an error while creating the annotation.

getDictionary

public COSDictionary getDictionary()
returns the dictionary.

Returns:
the dictionary

getRectangle

public PDRectangle getRectangle()
The annotation rectangle, defining the location of the annotation on the page in default user space units. This is usually required and should not return null on valid PDF documents. But where this is a parent form field with children, such as radio button collections then the rectangle will be null.

Returns:
The Rect value of this annotation.

setRectangle

public void setRectangle(PDRectangle rectangle)
This will set the rectangle for this annotation.

Parameters:
rectangle - The new rectangle values.

getAnnotationFlags

public int getAnnotationFlags()
This will get the flags for this field.

Returns:
flags The set of flags.

setAnnotationFlags

public void setAnnotationFlags(int flags)
This will set the flags for this field.

Parameters:
flags - The new flags.

getCOSObject

public COSBase getCOSObject()
Interface method for COSObjectable.

Specified by:
getCOSObject in interface COSObjectable
Returns:
This object as a standard COS object.

getAppearanceStream

public String getAppearanceStream()
This will get the name of the current appearance stream if any.

Returns:
The name of the appearance stream.

setAppearanceStream

public void setAppearanceStream(String as)
This will set the annotations appearance stream name.

Parameters:
as - The name of the appearance stream.

getAppearance

public PDAppearanceDictionary getAppearance()
This will get the appearance dictionary associated with this annotation. This may return null.

Returns:
This annotations appearance.

setAppearance

public void setAppearance(PDAppearanceDictionary appearance)
This will set the appearance associated with this annotation.

Parameters:
appearance - The appearance dictionary for this annotation.

isInvisible

public boolean isInvisible()
Get the invisible flag.

Returns:
The invisible flag.

setInvisible

public void setInvisible(boolean invisible)
Set the invisible flag.

Parameters:
invisible - The new invisible flag.

isHidden

public boolean isHidden()
Get the hidden flag.

Returns:
The hidden flag.

setHidden

public void setHidden(boolean hidden)
Set the hidden flag.

Parameters:
hidden - The new hidden flag.

isPrinted

public boolean isPrinted()
Get the printed flag.

Returns:
The printed flag.

setPrinted

public void setPrinted(boolean printed)
Set the printed flag.

Parameters:
printed - The new printed flag.

isNoZoom

public boolean isNoZoom()
Get the noZoom flag.

Returns:
The noZoom flag.

setNoZoom

public void setNoZoom(boolean noZoom)
Set the noZoom flag.

Parameters:
noZoom - The new noZoom flag.

isNoRotate

public boolean isNoRotate()
Get the noRotate flag.

Returns:
The noRotate flag.

setNoRotate

public void setNoRotate(boolean noRotate)
Set the noRotate flag.

Parameters:
noRotate - The new noRotate flag.

isNoView

public boolean isNoView()
Get the noView flag.

Returns:
The noView flag.

setNoView

public void setNoView(boolean noView)
Set the noView flag.

Parameters:
noView - The new noView flag.

isReadOnly

public boolean isReadOnly()
Get the readOnly flag.

Returns:
The readOnly flag.

setReadOnly

public void setReadOnly(boolean readOnly)
Set the readOnly flag.

Parameters:
readOnly - The new readOnly flag.

isLocked

public boolean isLocked()
Get the locked flag.

Returns:
The locked flag.

setLocked

public void setLocked(boolean locked)
Set the locked flag.

Parameters:
locked - The new locked flag.

isToggleNoView

public boolean isToggleNoView()
Get the toggleNoView flag.

Returns:
The toggleNoView flag.

setToggleNoView

public void setToggleNoView(boolean toggleNoView)
Set the toggleNoView flag.

Parameters:
toggleNoView - The new toggleNoView flag.

getAction

public PDAction getAction()
                   throws IOException
Get the action to be performed when this annotation is to be activated.

Returns:
The action to be performed when this annotation is activated.
Throws:
IOException - If there is an error creating the action.

setAction

public void setAction(PDAction action)
Set the annotation action. As of PDF 1.6 this is only used for Widget Annotations

Parameters:
action - The annotation action.

getActions

public PDAdditionalActions getActions()
Get the additional actions for this field. This will return null if there are no additional actions for this field. As of PDF 1.6 this is only used for Widget Annotations.

Returns:
The actions of the field.

setActions

public void setActions(PDAdditionalActions actions)
Set the actions of the field.

Parameters:
actions - The field actions.

getContents

public String getContents()
Get the "contents" of the field.

Returns:
the value of the contents.

setContents

public void setContents(String value)
Set the "contents" of the field.

Parameters:
value - the value of the contents.

setBorderStyle

public void setBorderStyle(PDBorderStyleDictionary bs)
This will set the border style dictionary, specifying the width and dash pattern used in drawing the line.

Parameters:
bs - the border style dictionary to set.

getBoderStyle

public PDBorderStyleDictionary getBoderStyle()
This will retrieve the border style dictionary, specifying the width and dash pattern used in drawing the line.

Returns:
the border style dictionary.

getModifiedDate

public String getModifiedDate()
This will retrieve the date and time the annotation was modified.

Returns:
the modified date/time (often in date format, but can be an arbitary string).

setModifiedDate

public void setModifiedDate(String m)
This will set the the date and time the annotation was modified.

Parameters:
m - the date and time the annotation was created.

getAnnotationName

public String getAnnotationName()
This will get the name, a string intended to uniquely identify each annotatoin within a page. Not to be confused with some annotations Name entry which impact the default image drawn for them.

Returns:
The identifying name for the Annotion.

setAnnotationName

public void setAnnotationName(String nm)
This will set the name, a string intended to uniquely identify each annotatoin within a page. Not to be confused with some annotations Name entry which impact the default image drawn for them.

Parameters:
nm - The identifying name for the annotation.

setColour

public void setColour(PDGamma c)
This will set the colour used in drawing various elements. As of PDF 1.6 these are : Background of icon when closed Title bar of popup window Border of a link annotation Colour is in DeviceRGB colourspace

Parameters:
c - colour in the DeviceRGB colourspace

getColour

public PDGamma getColour()
This will retrieve the colour used in drawing various elements. As of PDF 1.6 these are : Background of icon when closed Title bar of popup window Border of a link annotation Colour is in DeviceRGB colourspace

Returns:
PDGamma object representing the colour