Fixed Mustang to also store an embedded file under the /UF name - causes

problems when files are read by Intarsys.
This commit is contained in:
Ivan Vaklinov
2014-09-29 13:20:35 +03:00
committed by Thomas Chojecki
parent 28d6d3ca31
commit e37083d5e8

View File

@@ -25,7 +25,9 @@ import org.apache.jempbox.xmp.XMPSchemaDublinCore;
import org.apache.jempbox.xmp.XMPSchemaPDF; import org.apache.jempbox.xmp.XMPSchemaPDF;
import org.apache.jempbox.xmp.pdfa.XMPSchemaPDFAId; import org.apache.jempbox.xmp.pdfa.XMPSchemaPDFAId;
import org.apache.pdfbox.cos.COSArray; import org.apache.pdfbox.cos.COSArray;
import org.apache.pdfbox.cos.COSBase;
import org.apache.pdfbox.cos.COSDictionary; import org.apache.pdfbox.cos.COSDictionary;
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDDocumentCatalog; import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
import org.apache.pdfbox.pdmodel.PDDocumentInformation; import org.apache.pdfbox.pdmodel.PDDocumentInformation;
@@ -482,6 +484,12 @@ public class ZUGFeRDExporter {
fs.setEmbeddedFile(ef); fs.setEmbeddedFile(ef);
// In addition make sure the embedded file is set under /UF
dict = fs.getCOSDictionary();
COSDictionary efDict = (COSDictionary)dict.getDictionaryObject(COSName.EF);
COSBase lowerLevelFile = efDict.getItem(COSName.F);
efDict.setItem(COSName.UF, lowerLevelFile);
// now add the entry to the embedded file tree and set in the document. // now add the entry to the embedded file tree and set in the document.
efTree.setNames(Collections.singletonMap(filename, fs)); efTree.setNames(Collections.singletonMap(filename, fs));
PDDocumentNameDictionary names = new PDDocumentNameDictionary( PDDocumentNameDictionary names = new PDDocumentNameDictionary(