com.icesoft.pdf.pobjects.annotations
Class Annotation

java.lang.Object
  extended bycom.icesoft.pdf.pobjects.Dictionary
      extended bycom.icesoft.pdf.pobjects.annotations.Annotation
Direct Known Subclasses:
LinkAnnotation

public class Annotation
extends Dictionary

An Annotation class 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.

This class allows direct access to the a Annotations dictionary. Developers can take advantage of this information as they see fit. It is important to note that an annotations' rectangle coordinates are defined in the PDF document space. In order to map the rectangle coordinates to a view, they must be converted from the Cartesian plain to the the Java2D plain. The PageView method getPageBounds() can be used to locate the position of a page within its parent component.

Base class of all the specific Annotation types Taken from the PDF 1.6 spec, here is some relevant documentation, along with some additional commentary

8.4.1 Annotation Dictionaries

Key Type Value
Type name (Optional) The type of PDF object that this dictionary describes; if present, must be Annot for an annotation dictionary.
Subtype name (Required) The type of annotation that this dictionary describes.
Rect rectangle (Required) The annotation rectangle, defining the location of the annotation on the page in default user space units. getUserspaceLocation()
Contents text string (Optional) Text to be displayed for the annotation or, if this type of annotation does not display text, an alternate description of the annotation’s contents in human-readable form. In either case, this text is useful when extracting the document’s contents in support of accessibility to users with disabilities or for other purposes (see Section 10.8.2, “Alternate Descriptions”). See Section 8.4.5, “Annotation Types” for more details on the meaning of this entry for each annotation type.
P dictionary (Optional; PDF 1.3; not used in FDF files) An indirect reference to the page object with which this annotation is associated.
NM text string (Optional; PDF 1.4) The annotation name, a text string uniquely identifying it among all the annotations on its page.
M date or string (Optional; PDF 1.1) The date and time when the annotation was most recently modified. The preferred format is a date string as described in Section 3.8.3, “Dates,” but viewer applications should be prepared to accept and display a string in any format. (See implementation note 78 in Appendix H.)
F integer (Optional; PDF 1.1) A set of flags specifying various characteristics of the annotation (see Section 8.4.2, “Annotation Flags”). Default value: 0.
BS dictionary (Optional; PDF 1.2) A border style dictionary specifying the characteristics of the annotation’s border (see Section 8.4.3, “Border Styles”; see also implementation notes 79 and 86 in Appendix H).

Note: This entry also specifies the width and dash pattern for the lines drawn by line, square, circle, and ink annotations. See the note under Border (below) for additional information.

Table 8.13 summarizes the contents of the border style dictionary. If neither the Border nor the BS entry is present, the border is drawn as a solid line with a width of 1 point.
AP dictionary (Optional; PDF 1.2) An appearance dictionary specifying how the annotation is presented visually on the page (see Section 8.4.4, “Appearance Streams” and also implementation notes 79 and 80 in Appendix H). Individual annotation handlers may ignore this entry and provide their own appearances.

For convenience in managing appearance streams that are used repeatedly, the AP entry in a PDF document’s name dictionary (see Section 3.6.3, “Name Dictionary”) can contain a name tree mapping name strings to appearance streams. The name strings have no standard meanings; no PDF objects refer to appearance streams by name.
AS name (Required if the appearance dictionary AP contains one or more subdictionaries; PDF 1.2) The annotation’s appearance state, which selects the applicable appearance stream from an appearance subdictionary (see Section 8.4.4, “Appearance Streams” and also implementation note 79 in Appendix H).
Border array (Optional) An array specifying the characteristics of the annotation’s border. The border is specified as a rounded rectangle.

In PDF 1.0, the array consists of three numbers defining the horizontal corner radius, vertical corner radius, and border width, all in default user space units. If the corner radii are 0, the border has square (not rounded) corners; if the border width is 0, no border is drawn. (See implementation note 81 in Appendix H.)

In PDF 1.1, the array may have a fourth element, an optional dash array defining a pattern of dashes and gaps to be used in drawing the border. The dash array is specified in the same format as in the line dash pattern parameter of the graphics state (see “Line Dash Pattern” on page 187). For example, a Border value of [0 0 1 [3 2]] specifies a border 1 unit wide, with square corners, drawn with 3-unit dashes alternating with 2-unit gaps. Note that no dash phase is specified; the phase is assumed to be 0. (See implementation note 82 in Appendix H.)

Note: In PDF 1.2 or later, this entry may be ignored in favor of the BS entry (see above); see implementation note 86 in Appendix H.

Default value: [0 0 1].
BE dictionary (Optional; PDF 1.5) Some annotations (square, circle, and polygon) may have a BE entry, which is a border effect dictionary that specifies an effect to be applied to the border of the annotations. Its entries are listed in Table 8.14.
C array (Optional; PDF 1.1) An array of three numbers in the range 0.0 to 1.0, representing the components of a color in the DeviceRGB color space. This color is used for the following purposes:
  • The background of the annotation’s icon when closed
  • The title bar of the annotation’s pop-up window
  • The border of a link annotation
A dictionary (Optional; PDF 1.1) An action to be performed when the annotation is activated (see Section 8.5, “Actions”).

Note: This entry is not permitted in link annotations if a Dest entry is present (see “Link Annotations” on page 587). Also note that the A entry in movie annotations has a different meaning (see “Movie Annotations” on page 601).
AA dictionary (Optional; PDF 1.2) An additional-actions dictionary defining the annotation’s behavior in response to various trigger events (see Section 8.5.2, “Trigger Events”). At the time of publication, this entry is used only by widget annotations.
StructParent integer ((Required if the annotation is a structural content item; PDF 1.3) The integer key of the annotation’s entry in the structural parent tree (see “Finding Structure Elements from Content Items” on page 797).
OC dictionary (Optional; PDF 1.5) An optional content group or optional content membership dictionary (see Section 4.10, “Optional Content”) specifying the optional content properties for the annotation. Before the annotation is drawn, its visibility is determined based on this entry as well as the annotation flags specified in the F entry (see Section 8.4.2, “Annotation Flags”). If it is determined to be invisible, the annotation is skipped, as if it were not in the document.

8.4.2 Annotation Flags

The value of the annotation dictionary’s F entry is an unsigned 32-bit integer containing flags specifying various characteristics of the annotation. Bit positions within the flag word are numbered from 1 (low-order) to 32 (high-order). Table 8.12 shows the meanings of the flags; all undefined flag bits are reserved and must be set to 0.
Bit position Name Meaning
1 Invisible If set, do not display the annotation if it does not belong to one of the standard annotation types and no annotation handler is available. If clear, display such an unknown annotation using an appearance stream specified by its appearance dictionary, if any (see Section 8.4.4, “Appearance Streams”).
2 Hidden If set, do not display or print the annotation or allow it to interact with the user, regardless of its annotation type or whether an annotation handler is available. In cases where screen space is limited, the ability to hide and show annotations selectively can be used in combination with appearance streams (see Section 8.4.4, “Appearance Streams”) to display auxiliary pop-up information similar in function to online help systems. (See implementation note 83 in Appendix H.)
3 Print If set, print the annotation when the page is printed. If clear, never print the annotation, regardless of whether it is displayed on the screen. This can be useful, for example, for annotations representing interactive pushbuttons, which would serve no meaningful purpose on the printed page. (See implementation note 83 in Appendix H.)
4 NoZoom If set, do not scale the annotation’s appearance to match the magnification of the page. The location of the annotation on the page (defined by the upper-left corner of its annotation rectangle) remains fixed, regardless of the page magnification. See below for further discussion.
5 NoRotate If set, do not rotate the annotation’s appearance to match the rotation of the page. The upper-left corner of the annotation rectangle remains in a fixed location on the page, regardless of the page rotation. See below for further discussion.
6 NoView If set, do not display the annotation on the screen or allow it to interact with the user. The annotation may be printed (depending on the setting of the Print flag) but should be considered hidden for purposes of on-screen display and user interaction.
7 ReadOnly If set, do not allow the annotation to interact with the user. The annotation may be displayed or printed (depending on the settings of the NoView and Print flags) but should not respond to mouse clicks or change its appearance in response to mouse motions.

Note: This flag is ignored for widget annotations; its function is subsumed by the ReadOnly flag of the associated form field (see Table 8.66 on page 638).
8 Locked If set, do not allow the annotation to be deleted or its properties (including position and size) to be modified by the user. However, this flag does not restrict changes to the annotation’s contents, such as the value of a form field. (See implementation note 84 in Appendix H.)
9 ToggleNoView If set, invert the interpretation of the NoView flag for certain events. A typical use is to have an annotation that appears only when a mouse cursor is held over it; see implementation note 85 in Appendix H.

Since:
2.5
Author:
Mark Collette

Field Summary
 
Fields inherited from class com.icesoft.pdf.pobjects.Dictionary
entries, inited, library
 
Constructor Summary
Annotation(Library l, Hashtable h)
          Creates a new instance of an Annotation.
 
Method Summary
 boolean allowAlterProperties()
           
 boolean allowPrintNormalMode()
           
 boolean allowScreenDownMode()
           
 boolean allowScreenNormalMode()
           
protected  boolean allowScreenOrPrintRenderingOrInteraction()
           
 boolean allowScreenRolloverMode()
           
static Annotation buildAnnotation(Library library, Hashtable hashTable)
           
 Action getAction()
          Gets the action to be performed when the annotation is activated.
protected  Color getBorderColor()
           
 BorderStyle getBorderStyle()
           
 Page getPage()
           
 Annotation getParentAnnotation()
           
 String getSubType()
          Gets the type of annotation that this dictionary describes.
 Rectangle2D.Float getUserSpaceRectangle()
          Gets the annotation rectangle, and defines the location of the annotation on the page in default user space units.
protected  boolean isSupportedAnnotationType()
          The PDF spec defines rules for displaying annotation subtypes that the viewer does not recognise.
 void render(Graphics2D origG, int renderHintType, float totalRotation, float userZoom, boolean tabSelected)
           
protected  void renderAppearanceStream(Graphics2D g)
           
protected  void renderBorder(Graphics2D g)
           
protected  void renderBorderTabSelected(Graphics2D g)
           
 String toString()
          Returns a summary of the dictionary entries.
 
Methods inherited from class com.icesoft.pdf.pobjects.Dictionary
getEntries, getFloat, getInt, getLibrary, getNumber, getObject, getPObjectReference, init, setPObjectReference
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Annotation

public Annotation(Library l,
                  Hashtable h)
Creates a new instance of an Annotation.

Parameters:
l - document library.
h - dictionary entries.
Method Detail

buildAnnotation

public static Annotation buildAnnotation(Library library,
                                         Hashtable hashTable)

getSubType

public String getSubType()
Gets the type of annotation that this dictionary describes. For compatibility with the old com.icesoft.pdf.pobjects.Annotation.getSubType()

Returns:
subtype of annotation

getUserSpaceRectangle

public Rectangle2D.Float getUserSpaceRectangle()
Gets the annotation rectangle, and defines the location of the annotation on the page in default user space units. For compatibility with the old com.icesoft.pdf.pobjects.Annotation.getRectangle()

Returns:
rectangle of annotation

getAction

public Action getAction()
Gets the action to be performed when the annotation is activated. For compatibility with the old com.icesoft.pdf.pobjects.Annotation.getAction()

Returns:
action to be activated, if no action, null is returned.

allowScreenNormalMode

public boolean allowScreenNormalMode()

allowScreenRolloverMode

public boolean allowScreenRolloverMode()

allowScreenDownMode

public boolean allowScreenDownMode()

allowPrintNormalMode

public boolean allowPrintNormalMode()

allowAlterProperties

public boolean allowAlterProperties()

getBorderStyle

public BorderStyle getBorderStyle()

getParentAnnotation

public Annotation getParentAnnotation()

getPage

public Page getPage()

render

public void render(Graphics2D origG,
                   int renderHintType,
                   float totalRotation,
                   float userZoom,
                   boolean tabSelected)

renderAppearanceStream

protected void renderAppearanceStream(Graphics2D g)

renderBorder

protected void renderBorder(Graphics2D g)

renderBorderTabSelected

protected void renderBorderTabSelected(Graphics2D g)

getBorderColor

protected Color getBorderColor()
Returns:
A Color for the border, or null if none is to be used

allowScreenOrPrintRenderingOrInteraction

protected boolean allowScreenOrPrintRenderingOrInteraction()
Returns:
Whether this annotation may be shown in any way to the user

isSupportedAnnotationType

protected boolean isSupportedAnnotationType()
The PDF spec defines rules for displaying annotation subtypes that the viewer does not recognise. But, from a product point of view, we may or may not wish to make a best attempt at showing an unsupported annotation subtype, as that may make users think we're quality deficient, instead of feature deficient. Subclasses should override this, and return true, indicating that that particular annotation is supported.

Returns:
true, if this annotation is supported; else, false.

toString

public String toString()
Description copied from class: Dictionary
Returns a summary of the dictionary entries.

Overrides:
toString in class Dictionary
Returns:
dictionary values.