Package org.faceless.pdf2
Class AnnotationFile
- java.lang.Object
-
- org.faceless.pdf2.PDFAnnotation
-
- org.faceless.pdf2.AnnotationFile
-
- All Implemented Interfaces:
java.lang.Cloneable
public final class AnnotationFile extends PDFAnnotation
A subtype new
PDFAnnotation
that allows files to be attached to the PDF. File attachments do not work in the free Acrobat Reader - they require the full version of Acrobat. Currently the "encrypt separately" option added in Acrobat 7 is not supported, although if the document is encrypted the attachment will be encrypted with it.Note in revisions prior to 2.6 this class dealt with the file internally. In 2.6 the EmbeddedFile handling was moved to a separate class,
EmbeddedFile
, which now handles all the details of the actual file.- Since:
- 2.4.4
-
-
Constructor Summary
Constructors Constructor Description AnnotationFile()
Create a new File annotation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Object
clone()
EmbeddedFile
getFile()
Return the file embedded in this annotationvoid
putLiteral(java.lang.String key, java.lang.String tokens)
Put a literal token sequnce.void
rebuild()
Rebuild the annotation's appearance.void
setCustomAppearance(java.lang.String type, PDFCanvas canvas)
Set a custom appearance on thisAnnotationFile
.void
setFile(EmbeddedFile file)
Set the contents of this annotation to the specified embedded file.void
setRectangle(float x1, float y1, float x2, float y2)
Set the Rectangle for this annotation.void
setType(java.lang.String type, java.awt.Color color)
Set the type of attachment - the physical appearance 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, getType, 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
-
AnnotationFile
public AnnotationFile()
Create a new File annotation. To actually set the attachment, thesetFile()
method must be called.
-
-
Method Detail
-
setType
public void setType(java.lang.String type, java.awt.Color color)
Set the type of attachment - the physical appearance on the page. The type must be one of the four pre-defined types (PushPin, Graph, Paperclip or Tag) or anIllegalArgumentException
will be thrown.- Parameters:
type
- the type of attachment - one of the four values listed above.color
- the color of the attachment
-
setCustomAppearance
public void setCustomAppearance(java.lang.String type, PDFCanvas canvas)
Set a custom appearance on thisAnnotationFile
. This is non-standard but allowed; PDF viewers should have no trouble displaying this annotation, although edits to it may result in the appearance being lost.- Parameters:
type
- the optional "type" of this annotation, which may be one of the four standard types (PushPin, Graph, Paperclip or Tag), a custom value, ornull
for no type.canvas
- the canvas for the appearance, which must not be null and must be flushed.- Since:
- 2.27.2
-
setRectangle
public void setRectangle(float x1, float y1, float x2, float y2)
Set the Rectangle for this annotation. IfsetType()
has been called to use a standard appearance for this annotation, since 2.18.2 the width and height of the rectangle will be overridden to the size of that type's appearance. A custom appearance can be any size.- 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
-
setFile
public void setFile(EmbeddedFile file)
Set the contents of this annotation to the specified embedded file. The file can be shared - i.e. it can be referenced elsewhere in the PDF.- Parameters:
file
- the EmbeddedFile object to attach, which must not be null.- Since:
- 2.6
-
getFile
public EmbeddedFile getFile()
Return the file embedded in this annotation- Since:
- 2.6
-
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
-
-