pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tilman Hausherr <THaush...@t-online.de>
Subject Re: Embedding a file attachment (still) doesn't work...
Date Sun, 25 May 2014 16:17:30 GMT
Did you ever succeed with the embeddedfiles.java example?

https://svn.apache.org/repos/asf/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/EmbeddedFiles.java

Tilman

Am 25.05.2014 16:04, schrieb Gilad Denneboom:
> Hi all,
>
> I've seen this bug report (https://issues.apache.org/jira/browse/PDFBOX-811)
> which states the problem with embedding files is solved, but I can't get it
> to work (using PDFBox 1.8.5). Can anyone spot a mistake in my code before I
> post it as a new bug?
>
> Here's the relevant bit:
>
>          PDSimpleFileSpecification fs = new PDSimpleFileSpecification ();
>          fs.setFile("C:\\Temp\\Data.csv");
>
>          PDEmbeddedFilesNameTreeNode efTree = new
> PDEmbeddedFilesNameTreeNode();
>          Map efMap = new HashMap();
>          efMap.put( "Data.csv", fs );
>          efTree.setNames( efMap );
>
>          PDDocumentNameDictionary names = new PDDocumentNameDictionary(
> doc.getDocumentCatalog() );
>          names.setEmbeddedFiles( efTree );
>          doc.getDocumentCatalog().setNames(names);
>
> The resulting file contains no attachments.
>
> Once that is working I would also like to know how to use this code on a
> file with pre-existing attachments and make sure they are not removed in
> the process...
>
> Thanks in advance for any tips... Gilad
>


Mime
View raw message