Package com.snowtide.pdf.annot
Class FreeTextAnnotation
- java.lang.Object
-
- com.snowtide.pdf.annot.FreeTextAnnotation
-
- All Implemented Interfaces:
Annotation
,DocumentLocation
,Bounded
public class FreeTextAnnotation extends Object
An
Annotation
implementation that represents a PDF annotation of typeFreeText
.FreeTextAnnotation
s differ fromTextAnnotation
s in the following ways:- FreeTextAnnotations can be made to integrate with their parent PDF content seamlessly; TextAnnotations should never appear to be part of the regular PDF content.
- FreeTextAnnotations can contain 'rich text' -- XHTML/XFA content styled using CSS attributes.
The rich text and CSS style information can be retrieved using the
getRichContent()
andgetRichContentStyle()
functions, respectively.
FreeTextAnnotations should also contain a plain-text representation of their content suitable for indexing, etc., accessible via
Annotation.getContents()
.- Since:
- v1.3.5
- Version:
- ©2004-2024 Snowtide
-
-
Constructor Summary
Constructors Constructor Description FreeTextAnnotation()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Region
bounds()
Page
getAppearance()
Returns aPage
containing this annotation's rendered "appearance stream", if it explicitly defines one, null otherwise.String
getContents()
Returns the text content of this annotation.int
getJustificationInd()
Returns an int indicating how the text content of this annotation should be justified.String
getModificationDate()
Returns the date, in PDF date format, when this annotation was last modified.String
getName()
Returns the optional name for this annotation, which should uniquely identify it within a page.String
getRichContent()
Returns the rich text content held by this annotation.String
getRichContentStyle()
Returns the CSS style information held by this annotation that should be applied to the rich text content returned by thegetRichContent()
function when that content is displayed.String
getTypeCd()
Returns a String indicating what type of annotation this this.int
pageNumber()
This page number is 0-indexed, and may be used to retrieve aPage
object representing the page's content using theDocument#getPage(int)
function.
-
-
-
Method Detail
-
getJustificationInd
public int getJustificationInd()
Returns an int indicating how the text content of this annotation should be justified. Possible values:- 0 - left-justified
- 1 - centered
- 2 - right-justified
-
getRichContent
public String getRichContent()
Returns the rich text content held by this annotation. This content should conform to the XFA Text Specification, which is a subset of XHTML. For details on this, consult the subsection titled 'Rich Text Strings' in Section 8.6 of the PDF document reference. A plain text representation of this content should be available through thegetContents()
function.
-
getRichContentStyle
public String getRichContentStyle()
Returns the CSS style information held by this annotation that should be applied to the rich text content returned by thegetRichContent()
function when that content is displayed. This style information should conform to the CSS recommendations presented in the PDF document reference, Section 8.6, subsection 'Rich Text Strings'.
-
getContents
public String getContents()
Description copied from interface:Annotation
Returns the text content of this annotation. Some annotation types do not encode any text content; in such cases, those annotation type implementations will either return null from this function, or return an alternative descriptive text string that may be used to indicate the value or nature of this annotation.- Specified by:
getContents
in interfaceAnnotation
-
pageNumber
public int pageNumber()
Description copied from interface:DocumentLocation
This page number is 0-indexed, and may be used to retrieve aPage
object representing the page's content using theDocument.getPage(int)
function.If a page number is not available for some reason, then this method will return -1.
- Specified by:
pageNumber
in interfaceDocumentLocation
-
getName
public String getName()
Description copied from interface:Annotation
Returns the optional name for this annotation, which should uniquely identify it within a page.- Specified by:
getName
in interfaceAnnotation
-
getModificationDate
public String getModificationDate()
Description copied from interface:Annotation
Returns the date, in PDF date format, when this annotation was last modified. This date string may be parsed using thePDFDateParser
class. This function may return null if no modification date is present in the annotation data.- Specified by:
getModificationDate
in interfaceAnnotation
-
getTypeCd
public String getTypeCd()
Description copied from interface:Annotation
Returns a String indicating what type of annotation this this. These types are defined in Section 8.4.5 of the PDF Format Reference, and are returned with a leading forward slash.- Specified by:
getTypeCd
in interfaceAnnotation
-
getAppearance
public Page getAppearance() throws IOException
Description copied from interface:Annotation
Returns aPage
containing this annotation's rendered "appearance stream", if it explicitly defines one, null otherwise. (If an annotation does not define its own appearance explicitly, it is assumed that a PDF reader / consumer will provide a default rendering based on the annotation'stype
and associated data.) The contents of the page can be accessed and manipulated just like any "regular" page obtained from e.g.Document.getPage(int)
.- Specified by:
getAppearance
in interfaceAnnotation
- Throws:
IOException
-
-