You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Juan Bautista Magraner Bella <vi...@gmail.com> on 2015/04/03 10:33:23 UTC
Embed a video in PDF
Hi guys!
I'm trying to create a PDF that shows an embedded screen of a quicktime
video I've attached on it.
I guess the initial source code for attaching the file is:
PDEmbeddedFilesNameTreeNode efTree = new PDEmbeddedFilesNameTreeNode();
//first create the file specification, which holds the embedded file
PDComplexFileSpecification fs = new PDComplexFileSpecification();
fs.setFile( "video.mov" );
InputStream is = ...;
PDEmbeddedFile ef = new PDEmbeddedFile(doc, is );
//set some of the attributes of the embedded file
ef.setSubtype( "video/quicktime" );
ef.setSize( data.length );
ef.setCreationDate( new GregorianCalendar() );
fs.setEmbeddedFile( ef );
//now add the entry to the embedded file tree and set in the document.
Map efMap = new HashMap();
efMap.put( "My first attachment", fs );
efTree.setNames( efMap );
//attachments are stored as part of the "names" dictionary in the document
catalog
PDDocumentNameDictionary names = new PDDocumentNameDictionary(
doc.getDocumentCatalog() );
names.setEmbeddedFiles( efTree );
doc.getDocumentCatalog().setNames( names );
Now I would like to show the screen of the video inside the PDF. How can I
get that?
Kind Regards,
V. Clock