org.faceless.pdf2
Class PDFAnnotation

java.lang.Object
  extended byorg.faceless.pdf2.PDFObject
      extended byorg.faceless.pdf2.PDFMap
          extended byorg.faceless.pdf2.PDFAnnotation
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
AnnotationLink, AnnotationNote, AnnotationStamp, WidgetAnnotation

public class PDFAnnotation
extends org.faceless.pdf2.PDFMap

A PDFAnnotation allows the user to interact with the generated PDF document, by adding / viewing rubber-stamps, popup notes hyperlinks and so on. A special subclass of annotation, called a Widget, is also used to display FormElement objects on the page. Since version 2.0, the various types of annotation have been split into unique subclasses. This class contains the methods that are common to all of them.

Since:
1.1

Method Summary
 boolean equals(Object o)
           
 Calendar getCreationDate()
          Return the date when the annotation was first created if specified, or null otherwise.
 PDFAnnotation getInReplyTo()
          Return the PDFAnnotation that this annotation is in reply to, or null if not specified.
 Calendar getModifyDate()
          Return the date when the annotation was last modified if specified, or null otherwise.
 PDFPage getPage()
          Return the page that this annotation is on, or null if it a new annotation which has not yet been placed on a page
 float[] getRectangle()
          Return the rectangle this annotation applies to on the page, or null if no rectangle applies for this type of annotation.
 String getSubject()
          Get the subject of the annotation, as set by setSubject(java.lang.String)
 String getType()
          Return the type of annotation.
 String getUniqueID()
          Return the unique ID for this annotation, if set.
 boolean isPrintable()
          Returns whether the annotation is included when the document is printed (true) or not (false)
 boolean isReadOnly()
           Return whether the annotation to "read-only".
 boolean isVisible()
          Returns whether the annotation is visible on the screen (true) or not (false)
 void setInReplyTo(PDFAnnotation annotation)
          Set which annotation this annotation is in reply to.
 void setPage(PDFPage page)
          Set the page for this annotation.
 void setPrintable(boolean printable)
          Set whether the annotation is included when the document is printed.
 void setReadOnly(boolean readonly)
           Set the annotation to "read-only", or not.
 void setRectangle(float x1, float y1, float x2, float y2)
          Set the rectangle for the annotation.
 void setSubject(String subject)
          Set the subject of the annotation.
 void setUniqueID(String id)
          Set the unique ID for this annotation.
 void setVisible(boolean visible)
          Set whether the annotation is visible on screen.
 String toString()
           
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

setRectangle

public void setRectangle(float x1,
                         float y1,
                         float x2,
                         float y2)
Set the rectangle for the annotation.

Note that all co-ordinates are in absolute page co-ordinates. This means they are measured in points from the bottom-left hand corner of the page, regardless of any calls to PDFPage.rotate(float, float, double) or PDFPage.setUnits(float, int) that have been made. This restriction is part of the PDF specification.

Parameters:
x1 - the X co-ordinate of the bottom-left corner of the rectangle
y1 - the Y co-ordinate of the bottom-left corner of the rectangle
x2 - the X co-ordinate of the top-right corner of the rectangle
y2 - the Y co-ordinate of the top-right corner of the rectangle

getRectangle

public float[] getRectangle()
Return the rectangle this annotation applies to on the page, or null if no rectangle applies for this type of annotation. See the setRectangle() method for a discussion on units.

Returns:
the rectangle for this annotation, in the form of an array (x1, y1, x2, y2)
Since:
1.1.12
See Also:
setRectangle(float, float, float, float)

getSubject

public String getSubject()
Get the subject of the annotation, as set by setSubject(java.lang.String)

Since:
2.0

setSubject

public void setSubject(String subject)
Set the subject of the annotation. This is an Acrobat 6.0 feature only, but will safely be ignored by earlier viewers.

Parameters:
subject - a brief summary of the contents of the annotation
Since:
2.0

getPage

public PDFPage getPage()
Return the page that this annotation is on, or null if it a new annotation which has not yet been placed on a page

Since:
1.1.23

setPage

public void setPage(PDFPage page)
Set the page for this annotation. This is useful when moving annotations between documents or across pages - when simply adding a new annotation to a page, this method is identical to calling PDFPage.getAnnotations().add()

Since:
1.1.23

setVisible

public void setVisible(boolean visible)
Set whether the annotation is visible on screen. By default, all new annotations are visible.

Parameters:
visible - whether the annotation should be displayed on the screen
Since:
1.1.23

setPrintable

public void setPrintable(boolean printable)
Set whether the annotation is included when the document is printed. By default, all new annotations (except for hyperlinks) are printed.

Parameters:
printable - whether the annotation should be printed
Since:
1.1.23

isVisible

public boolean isVisible()
Returns whether the annotation is visible on the screen (true) or not (false)

Since:
1.1.23

isPrintable

public boolean isPrintable()
Returns whether the annotation is included when the document is printed (true) or not (false)

Since:
1.1.23

isReadOnly

public boolean isReadOnly()

Return whether the annotation to "read-only". Read-only annotations cannot be moved or deleted and do not respond to mouse clicks in Acrobat.

Note this value is ignored for WidgetAnnotation objects - see the FormElement.isReadOnly() method instead.

Since:
2.0
See Also:
setReadOnly(boolean), FormElement.isReadOnly()

setReadOnly

public void setReadOnly(boolean readonly)

Set the annotation to "read-only", or not. Read-only annotations cannot be moved or deleted and do not respond to mouse clicks in Acrobat

Additionally, using Acrobat there is no way to change this flag, so fields set to read-only using this method will basically stay that way unless edited with an API like this one. This makes this setting useful for placing "permanent" annotations on a page.

Note this value is ignored for WidgetAnnotation objects - see the FormElement.setReadOnly(boolean) method instead

Since:
2.0

getModifyDate

public Calendar getModifyDate()
Return the date when the annotation was last modified if specified, or null otherwise.

Since:
2.0 - prior to that this method was called getLastModified

getCreationDate

public Calendar getCreationDate()
Return the date when the annotation was first created if specified, or null otherwise. Note for annotations not created with Acrobat 6 or later, this will be the same Date as getModifyDate()

Since:
2.0

getType

public String getType()
Return the type of annotation. Could be one of "Text" (for AnnotationNotes), "Link", (for AnnotationLinks), "Stamp" (for AnnotationStamps), "Widget" (for WidgetAnnotations), or "FreeText", "Line", "Square", "Circle", "Polygon", "Polyline", "Highlight", "Underline", "Squiggly", "StrikeOut", "Caret", "Ink", "Popup", "FileAttachment", "Sound", "Movie", "Screen", "PrinterMark" or "TrapNet", all of which only have only basic support with this API.

Since:
1.1.12

getInReplyTo

public PDFAnnotation getInReplyTo()
Return the PDFAnnotation that this annotation is in reply to, or null if not specified. Note for annotations not created with Acrobat 6 or later, this will always be null

Since:
2.0

getUniqueID

public String getUniqueID()
Return the unique ID for this annotation, if set. This is the "NM" field, added as an optional attribute in Acrobat 5.0, and is usually in the form of a 15-30 random characters. If no unique ID is set, this method returns null.

Since:
2.0.8

setUniqueID

public void setUniqueID(String id)
Set the unique ID for this annotation. See the getUniqueID() method for more information. Note that it is down to the user to ensure that the unique ID generated is actually unique.

Parameters:
id - the unique ID to assign to this annotation
Since:
2.0.8

setInReplyTo

public void setInReplyTo(PDFAnnotation annotation)
Set which annotation this annotation is in reply to. This is an Acrobat 6 or later only feature, although it will safely be ignored by earlier viewers. Note the two annotations must be on the same page, otherwise this setting will be ignored.

Parameters:
annotation - the annotation this is in reply to, or null to remove the current value
Since:
2.0

toString

public String toString()

equals

public boolean equals(Object o)


Copyright © 2001-2004 Big Faceless Organization