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

Reply via email to