Class AnnotationLink
- java.lang.Object
-
- org.faceless.pdf2.PDFAnnotation
-
- org.faceless.pdf2.AnnotationLink
-
- All Implemented Interfaces:
Cloneable
public final class AnnotationLink extends PDFAnnotation
A subtype new
PDFAnnotationthat performs the specified action when clicked. This can be used to create an HTML-style hyperlink, play a sound, or perform some otherPDFAction.- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description AnnotationLink()Create a new Link annotation with a defaultsetStyle(org.faceless.pdf2.PDFStyle)ofnull
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Objectclone()PDFActiongetAction()Return the action performed by this hyperlinkfloat[]getCorners()Return the corners of the Annotation as specified bysetCorners().ShapegetCornersAsShape()Return the outline of the annotation as a shapefloat[]getRectangle()Return the rectangle this annotation applies to on the page, or null if no rectangle applies for this type of annotation.PDFStylegetStyle()Returns the style used to draw the link on the page.voidsetAction(PDFAction action)Set the action for this hyperlinkvoidsetCorners(float[] corners)Set a series of corners of the quadrilateral(s) that encompass the text underlying this annotation.voidsetCorners(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.voidsetCorners(Shape shape)Attempt to set the corners of the annotation to the specified shape.voidsetRectangle(float x1, float y1, float x2, float y2)Set the rectangle for the annotation - where it is on the page.voidsetStyle(PDFStyle style)Set the style for this hyperlink annotation.StringtoString()-
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, getReplies, getReviews, getSubject, getType, getUniqueID, getUserData, getXMP, hasAppearanceState, isContentLocked, isPositionLocked, isPrintable, isReadOnly, isVisible, putUserData, rebuild, removePropertyChangeListener, setAction, setAuthor, setColor, setContents, setCreationDate, setDefaultColorSpace, setInReplyTo, setLocale, setLocked, setMetaData, setModifyDate, setOpacity, setOptionalContentDescriptor, setPage, setPrintable, setReadOnly, setSubject, setUniqueID, setVisible
-
-
-
-
Constructor Detail
-
AnnotationLink
public AnnotationLink()
Create a new Link annotation with a defaultsetStyle(org.faceless.pdf2.PDFStyle)ofnull
-
-
Method Detail
-
setAction
public void setAction(PDFAction action)
Set the action for this hyperlink
-
getAction
public PDFAction getAction()
Return the action performed by this hyperlink
-
getRectangle
public float[] getRectangle()
Description copied from class:PDFAnnotationReturn the rectangle this annotation applies to on the page, or null if no rectangle applies for this type of annotation. See thesetRectangle()method for a discussion on units.- Overrides:
getRectanglein classPDFAnnotation- Returns:
- the rectangle for this annotation, in the form of an array (x1, y1, x2, y2)
- See Also:
PDFAnnotation.setRectangle(float, float, float, float)
-
setStyle
public void setStyle(PDFStyle style)
Set the style for this hyperlink annotation. Parameters from the style that are used include
LineColor,DashPattern,LineWeightingandFormStyle(although Acrobat 4 and earlier will ignore the FormStyle)Alternatively the style may be
nullto prevent this link having any visible appearance on the page- Parameters:
style- the style to draw the link in - may benull
-
getStyle
public PDFStyle getStyle()
Returns the style used to draw the link on the page.- Since:
- 2.11.6
- See Also:
setStyle(org.faceless.pdf2.PDFStyle)
-
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. This can be used to create the annotation on an angle, although viewers prior to Acrobat 7.0 will not recognise the rotation. Since 2.11.6 there is no need to call
setRectangle(org.faceless.pdf2.LayoutBox.Box, float, float)as well as this method.While the coordinates can describe any quadrilateral, some viewers may behave incorrectly if it is not rectangular (eg 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- Since:
- 2.4
-
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.6
-
setCorners
public void setCorners(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 shape can be any shape, some viewers may behave incorrectly if it is not 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:PDFAnnotationSet 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
AnnotationLinkandAnnotationStampannotations, this is the rectangle containing the hyperlink area or stamp. - For
AnnotationNoteannotations, 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:
setRectanglein 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
-
getCornersAsShape
public Shape getCornersAsShape()
Return the outline of the annotation as a shape- Since:
- 2.23.2
-
getCorners
public float[] getCorners()
Return the corners of the Annotation as specified bysetCorners().- Returns:
- an array of 8xn points as set by
setCorners() - Since:
- 2.4
-
toString
public String toString()
-
-