Class AnnotationRichMedia

  • All Implemented Interfaces:
    Cloneable

    public class AnnotationRichMedia
    extends PDFAnnotation

    This class is a type of PDFAnnotation that acts as a container for interactive media such as flash or video.

    For example, to embed an MP4 video in a page:

     EmbeddedFile file = new EmbeddedFile(new File("myfile.mp4"));
     file.setType("video/mp4");
     AnnotationRichMedia annot = new AnnotationRichMedia();
     annot.setEmbeddedFile(file);
     annot.setPage(page);
     annot.setRectangle(100, 600, 300, 800);
     
    Since:
    2.11.14
    • Constructor Detail

      • AnnotationRichMedia

        public AnnotationRichMedia()
        Creates a new rich media annotation.
    • Method Detail

      • setFile

        public void setFile​(EmbeddedFile file)

        Set the content of this rich media annotation to a particular file. This can be used to embed a video. The supplied file must have a type which is used to inform the API as to the best way to embed the file.

        The current list of supported type is deliberately left undefined but includes "video/mp4", "video/quicktime", both have which have been tested with Acrobat.

        Parameters:
        file - the file to embed, which which have a type and should have both a name and description.
        Since:
        2.24.2
      • setAppearance

        public void setAppearance​(PDFCanvas canvas)
        If the RichMedia is not loaded yet, or cannot be loaded for some reason, this method can set a fallback visualization for the annotation. The supplied canvas will be stretched to fit the final rectangle of the annotation, so the size does not have to match.
        Parameters:
        canvas - the apperarance of the annotation, or null for no appearance.
        Since:
        2.24.2
      • setEmbeddedFile

        public void setEmbeddedFile​(EmbeddedFile file,
                                    String type,
                                    String activationCondition,
                                    String deactivationCondition)
        Deprecated.
        Flash video is unlikely to work, and we reecommend setFile(org.faceless.pdf2.EmbeddedFile)
        Sets the embedded rich media file to use within this annotation.
        Parameters:
        file - the embedded file
        type - the primary content type of the file. Currently the only valid value is "Flash"
        activationCondition - the condition under which the media will be activated. Valid values are "XA" (script or user activation), "PO" (activated when page receives focus), and "PV" (activated when page becomes visible)
        deactivationCondition - the condition under which the media will be deactivated. Valid values are "XD" (script or user deactivation), "PC" (deactivated when page loses focus), and "PI" (deactivated when no part of the page is any longer visible).
      • toString

        public String toString()