[
https://issues.apache.org/jira/browse/PDFBOX-811?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13099711#comment-13099711
]
Daniel Deng commented on PDFBOX-811:
------------------------------------
I compared the output pdfs between version 0.7.3 and version 1.6.0. The 1.6.0
one has the following extra statement under the EmbeddedFilesNameTreeNode obj :
/Limits [(My first attachment) (My first attachment)]
It seems that this line is the cause of the problem. However I couldn't find
any API to get rid of this line, so I copied the setNames method in
org.apache.pdfbox.pdmodel.common.PDNameTreeNode and modified it to a new method
:
/**
* A patched setName method to resolve the problem that attachment does
not
* show up on the list.
*
* @param names
*/
public void setNamesWithoutLimit( Map<String, ? extends COSObjectable>
names )
{
if( names == null )
{
node.setItem( "Names", (COSObjectable)null );
node.setItem( COSName.LIMITS, (COSObjectable)null);
}
else
{
COSArray array = new COSArray();
List<String> keys = new ArrayList<String>(names.keySet());
Collections.sort(keys);
for (String key : keys) {
array.add(new COSString(key));
array.add(names.get(key));
}
//just remove the setLimit calls here
node.setItem("Names", array);
}
}
and called this method instead of efTree.setName() in the example. It seems
solve the problem and works fine in my project. But I am new to pdf so that I
don't know whether it will cause any side effect.
> EmbeddedFiles example does not work
> -----------------------------------
>
> Key: PDFBOX-811
> URL: https://issues.apache.org/jira/browse/PDFBOX-811
> Project: PDFBox
> Issue Type: Bug
> Components: PDModel
> Affects Versions: 1.2.1
> Environment: Java 1.6, Windows XP
> Reporter: Markus Horehled
>
> Running the EmbeddedFiles example does not work properly. Obviously it has
> stopped working with Version 1.1.0 already at least. I've tried the same
> example with pdfbox 0.7.3 and there it is working without any problems.
> Although it seems (according to the document's size) that the file is
> embedded, there is no entry visible in the PDF's attachment/document section
> ...
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira