据我所知,PDFBox不包含单一专用该任务的方法。另一方面,使用现有的通用 PDFBox方法来实现它是相当容易的。
首先,任务就有效地定义做相当于
stamper.makePackage(PdfName.T);
使用PDFBox的。在iText的该方法被记录为:
/**
* This is the most simple way to change a PDF into a
* portable collection. Choose one of the following names:
* <ul>
* <li>PdfName.D (detailed view)
* <li>PdfName.T (tiled view)
* <li>PdfName.H (hidden)
* </ul>
* Pass this name as a parameter and your PDF will be
* a portable collection with all the embedded and
* attached files as entries.
* @param initialView can be PdfName.D, PdfName.T or PdfName.H
*/
public void makePackage(final PdfName initialView)
因此,我们需要改变一个PDF(相当最低限度),使之成为便携式采集与平铺视图。
根据第12.3.5 ISO 32000-1的“集合”(我没有第二部分还没有),这意味着我们必须添加一个集合词典到PDF目录与查看条目以值T。因此:
PDDocument pdDocument = PDDocument.load(...);
COSDictionary collectionDictionary = new COSDictionary();
collectionDictionary.setName(COSName.TYPE, "Collection");
collectionDictionary.setName("View", "T");
PDDocumentCatalog catalog = pdDocument.getDocumentCatalog();
catalog.getCOSObject().setItem("Collection", collectionDictionary);
pdDocument.save(...);
来源
2017-10-09 13:03:01
mkl