Class AnnotationFile

  • All Implemented Interfaces:
    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 Detail

      • AnnotationFile

        public AnnotationFile()
        Create a new File annotation. To actually set the attachment, the setFile() method must be called.
    • Method Detail

      • setType

        public void setType​(String type,
                            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 an IllegalArgumentException will be thrown.
        Parameters:
        type - the type of attachment - one of the four values listed above.
        color - the color of the attachment
      • setRectangle

        public void setRectangle​(float x1,
                                 float y1,
                                 float x2,
                                 float y2)
        Set the Rectangle for this annotation. Since 2.18.2, for an AnnotationFile object, only the first two co-ordinates are used - x2 and y2 are derived from x1 and y1 and the size of the annotation.
        Overrides:
        setRectangle in class PDFAnnotation
        Parameters:
        x1 - the X co-ordinate of the bottom-left corner of the rectangle
        y1 - the Y co-ordinate of the bottom-left corner of the rectangle
        x2 - the X co-ordinate of the top-right corner of the rectangle
        y2 - 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.
        Parameters:
        file - the EmbeddedFile object to attach
        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 a PropertyChangeEvent) is run on a specific thread.
        Overrides:
        rebuild in class PDFAnnotation
      • toString

        public String toString()