Class AnnotationMarkup
- java.lang.Object
-
- org.faceless.pdf2.PDFAnnotation
-
- org.faceless.pdf2.AnnotationMarkup
-
- All Implemented Interfaces:
java.lang.Cloneable
public class AnnotationMarkup extends PDFAnnotation
This class represents the type ofPDFAnnotation
created by the "Text Edit" option in Acrobat 6. There are several different subtypes of this annotation - "Highlight", "Underline", "Squiggly" or "StrikeOut", all of which can be determined by the crossed-out or underlined text in the PDF.- Since:
- 2.3.6
-
-
Constructor Summary
Constructors Constructor Description AnnotationMarkup(java.lang.String type)
Create a new Markup Annotation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Object
clone()
float[]
getCorners()
Return the four corners of the text underlying the annotationjava.lang.String
getType()
Return the type of Markup Annotation - "Highlight", "Squiggly", "Underline" or "StrikeOut" (or, theoretically, another unknown value).void
putLiteral(java.lang.String key, java.lang.String tokens)
Put a literal token sequnce.void
rebuild()
Rebuild the annotation's appearance.void
setCorners(float[] corners)
Set a series of corners of the quadrilateral(s) that encompass the text underlying this annotation.void
setCorners(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
Set the four corners (x1,y1) (x2,y2) (x3,y3) (x4,y4) of the quadrilateral that encompasses the text underlying this annotation.void
setCorners(java.awt.Shape shape)
Attempt to set the corners of the annotation to the specified shape.void
setRectangle(float x1, float y1, float x2, float y2)
Set the rectangle for the annotation - where it is on the page.java.lang.String
toString()
-
Methods inherited from class org.faceless.pdf2.PDFAnnotation
addPropertyChangeListener, addReview, flatten, getAction, getAssociatedFiles, getAuthor, getColor, getContents, getCreationDate, getDefaultColorSpace, getInReplyTo, getLocale, getMetaData, getModifyDate, getOpacity, getOptionalContentDescriptor, getPage, getPopup, getRectangle, getReplies, getReviews, getSubject, getUniqueID, getUserData, getXMP, hasAppearanceState, isContentLocked, isPositionLocked, isPrintable, isReadOnly, isVisible, putUserData, removePropertyChangeListener, setAction, setAuthor, setColor, setContents, setCreationDate, setDefaultColorSpace, setInReplyTo, setLocale, setLocked, setMetaData, setModifyDate, setOpacity, setOptionalContentDescriptor, setPage, setPrintable, setReadOnly, setSubject, setUniqueID, setVisible
-
-
-
-
Constructor Detail
-
AnnotationMarkup
public AnnotationMarkup(java.lang.String type)
Create a new Markup Annotation. The type of markup must be specified, and may be one of:- "Highlight" (highlighted text)
- "Underline" (underlined text)
- "Squiggly" (squiggly underlined text)
- "StrikeOut" (strikeout text)
- Parameters:
type
- the type of Markup Annotation
-
-
Method Detail
-
getType
public java.lang.String getType()
Return the type of Markup Annotation - "Highlight", "Squiggly", "Underline" or "StrikeOut" (or, theoretically, another unknown value).- Overrides:
getType
in classPDFAnnotation
- Returns:
- the type of Markup annotation
-
setCorners
public void setCorners(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
Set the four corners (x1,y1) (x2,y2) (x3,y3) (x4,y4) of the quadrilateral that encompasses the text underlying this annotation. The baseline of the text this annotation is highlighting is assumed to run from (x1,y1) to (x2,y2).
While the coordinates can describe any quadrilateral, some viewers may behave incorrectly if they are not all rectangular (e.g. Preview.app on OS X).
- Parameters:
x1
- the X co-ordinate of the bottom-left corner of the texty1
- the Y co-ordinate of the bottom-left corner of the textx2
- the X co-ordinate of the bottom-right corner of the texty2
- the Y co-ordinate of the bottom-right corner of the textx3
- the X co-ordinate of the top-left corner of the texty3
- the Y co-ordinate of the top-left corner of the textx4
- the X co-ordinate of the top-right corner of the texty4
- the Y co-ordinate of the top-right corner of the text
-
setCorners
public void setCorners(float[] corners)
Set a series of corners of the quadrilateral(s) that encompass the text underlying this annotation. The points are specified in the same order as for the other
setCorners()
method. The supplied array must be 8xn long, specifying the n quadrilaterals that make up the annotation.While the coordinates can describe any sequence of quadrilaterals, some viewers may behave incorrectly if they are not all rectangular (e.g. Preview.app on OS X).
- Parameters:
corners
- an array of 8xn values, each group of 8 specified as (x1,y1, x2,y2, x3,y3, x4,y4)- Since:
- 2.11.3
-
setCorners
public void setCorners(java.awt.Shape shape)
Attempt to set the corners of the annotation to the specified shape. This method will attempt to break the shape up into quadrilaterals, as required by the PDF specification. If for any reason the specified Shape cannot be split (and currently, only areas with no holes can be), then this method will throw an
IllegalArgumentException
.While the coordinates can describe any Shape, some viewers may behave incorrectly if it is not all rectangular (e.g. Preview.app on OS X).
- Since:
- 2.18.2
-
setRectangle
public void setRectangle(float x1, float y1, float x2, float y2)
Description copied from class:PDFAnnotation
Set the rectangle for the annotation - where it is on the page. Every annotation must have a rectangle set - if it's not set when the document is written, it's forced to (0,0,0,0).- For
AnnotationLink
andAnnotationStamp
annotations, this is the rectangle containing the hyperlink area or stamp. - For
AnnotationNote
annotations, whether this method adjusts the location of the icon or the popup window depends on whether the annotation is closed or open at the time of the call to this method. When closed, the icon is positioned at x1,y2
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)
orPDFPage.setUnits(float, int)
that have been made. This restriction is part of the PDF specification.- Overrides:
setRectangle
in classPDFAnnotation
- Parameters:
x1
- the X co-ordinate of the bottom-left corner of the rectangley1
- the Y co-ordinate of the bottom-left corner of the rectanglex2
- the X co-ordinate of the top-right corner of the rectangley2
- the Y co-ordinate of the top-right corner of the rectangle
- For
-
getCorners
public float[] getCorners()
Return the four corners of the text underlying the annotation- Returns:
- an array of 8xn points, as set by
setCorners()
-
rebuild
public void rebuild()
Description copied from class:PDFAnnotation
Rebuild the annotation's appearance. This will be done automatically when required, usually just before saving the PDF or rasterizing it to a bitmap. However this method can be called explicitly if necessary, usually to ensure the rebuild (which may fire aPropertyChangeEvent
) is run on a specific thread.- Overrides:
rebuild
in classPDFAnnotation
-
toString
public java.lang.String toString()
-
putLiteral
public void putLiteral(java.lang.String key, java.lang.String tokens)
Put a literal token sequnce. For debugging- Parameters:
key
- the keytokens
- the token sequence, eg "true" or "/foo" or "[/Foo/Bar]". No refs, just direct objects.
-
clone
protected java.lang.Object clone()
- Overrides:
clone
in classjava.lang.Object
-
-