"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "examples/src/main/java/org/apache/pdfbox/examples/pdmodel/EmbeddedFiles.java" between
pdfbox-2.0.23-src.zip and pdfbox-2.0.24-src.zip

About: Apache PDFBox is a Java PDF library tool that allows creation of new PDF documents, manipulation of existing documents and the ability to extract content from documents.

EmbeddedFiles.java  (pdfbox-2.0.23-src):EmbeddedFiles.java  (pdfbox-2.0.24-src)
skipping to change at line 99 skipping to change at line 99
ByteArrayInputStream fakeFile = new ByteArrayInputStream(data); ByteArrayInputStream fakeFile = new ByteArrayInputStream(data);
PDEmbeddedFile ef = new PDEmbeddedFile(doc, fakeFile ); PDEmbeddedFile ef = new PDEmbeddedFile(doc, fakeFile );
//now lets some of the optional parameters //now lets some of the optional parameters
ef.setSubtype( "text/plain" ); ef.setSubtype( "text/plain" );
ef.setSize( data.length ); ef.setSize( data.length );
ef.setCreationDate( new GregorianCalendar() ); ef.setCreationDate( new GregorianCalendar() );
// use both methods for backwards, cross-platform and cross-language compatibility. // use both methods for backwards, cross-platform and cross-language compatibility.
fs.setEmbeddedFile( ef ); fs.setEmbeddedFile( ef );
fs.setEmbeddedFileUnicode(ef); fs.setEmbeddedFileUnicode(ef);
fs.setFileDescription("Very interesting file");
// create a new tree node and add the embedded file // create a new tree node and add the embedded file
PDEmbeddedFilesNameTreeNode treeNode = new PDEmbeddedFilesNameTreeNo de(); PDEmbeddedFilesNameTreeNode treeNode = new PDEmbeddedFilesNameTreeNo de();
treeNode.setNames( Collections.singletonMap( "My first attachment", fs ) ); treeNode.setNames( Collections.singletonMap( "My first attachment", fs ) );
// add the new node as kid to the root node // add the new node as kid to the root node
List<PDEmbeddedFilesNameTreeNode> kids = new ArrayList<PDEmbeddedFil esNameTreeNode>(); List<PDEmbeddedFilesNameTreeNode> kids = new ArrayList<PDEmbeddedFil esNameTreeNode>();
kids.add(treeNode); kids.add(treeNode);
efTree.setKids(kids); efTree.setKids(kids);
// add the tree to the document catalog // add the tree to the document catalog
PDDocumentNameDictionary names = new PDDocumentNameDictionary( doc.g etDocumentCatalog() ); PDDocumentNameDictionary names = new PDDocumentNameDictionary( doc.g etDocumentCatalog() );
names.setEmbeddedFiles( efTree ); names.setEmbeddedFiles( efTree );
doc.getDocumentCatalog().setNames( names ); doc.getDocumentCatalog().setNames( names );
// show attachments panel in some viewers // show attachments panel in some viewers
doc.getDocumentCatalog().setPageMode(PageMode.USE_ATTACHMENTS); doc.getDocumentCatalog().setPageMode(PageMode.USE_ATTACHMENTS);
doc.save( file ); doc.save( file );
} }
finally finally
{ {
if( doc != null ) if( doc != null )
{ {
doc.close(); doc.close();
} }
} }
} }
 End of changes. 2 change blocks. 
1 lines changed or deleted 1 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)