Package org.faceless.pdf2
Class AnnotationRichMedia
- java.lang.Object
-
- org.faceless.pdf2.PDFAnnotation
-
- org.faceless.pdf2.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 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.setFile(file); annot.setPage(page); annot.setRectangle(100, 600, 300, 800);
- Since:
- 2.11.14
-
-
Constructor Summary
Constructors Constructor Description AnnotationRichMedia()
Creates a new rich-media annotation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Object
clone()
Map<String,EmbeddedFile>
getFiles()
Return an unmodifiable map of all the assets in this rich-media annotation.void
putLiteral(String key, String tokens)
Put a literal token sequnce.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.void
setFile(EmbeddedFile file)
Set the content of this rich media annotation to a particular file.void
setPreferredType(String type)
Set the preferred type of rich-media this annotation should represent.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, rebuild, removePropertyChangeListener, setAction, setAuthor, setColor, setContents, setCreationDate, setDefaultColorSpace, setInReplyTo, setLocale, setLocked, setMetaData, setModifyDate, setOpacity, setOptionalContentDescriptor, setPage, setPrintable, setReadOnly, setRectangle, setSubject, setUniqueID, setVisible
-
-
-
-
Method Detail
-
setPreferredType
public void setPreferredType(String type)
Set the preferred type of rich-media this annotation should represent. Valid values are "Screen" or "RichMedia" - anything will let the API choose an appropriate value. This must be called beforesetFile(org.faceless.pdf2.EmbeddedFile)
to have an effect.- Since:
- 2.26.3
-
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 the following, all of which have had basic testing in Acrobat in 2022. However please bear in mind that support has come and gone over the years and is likely to be at least partly platform dependent.
- video/mp4 (h264 codec strongly recommended)
- audio/mpeg (aka mp3)
- model/u3d
- model/prc
- 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
-
getFiles
public Map<String,EmbeddedFile> getFiles()
Return an unmodifiable map of all the assets in this rich-media annotation. For many annotations this will contain only one item.- Since:
- 2.26.3
-
toString
public String toString()
-
putLiteral
public void putLiteral(String key, 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.
-
-