私が知る限り、PDFBoxにはという単一の専用のメソッドが含まれていません。一方、それを実装するには、既存の PDFBoxメソッドを使用するのはかなり簡単です。すべての
まず、タスクを効果的にPDFBoxを使用して
stamper.makePackage(PdfName.T);
と同等の操作を行うように定義されています。したがって、我々はそれタイル張りのビューを備えたポータブルコレクションにするために(かなり最小限)PDFを変更する必要が
/**
* 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)
:iTextの中にその方法は、以下のように記載されています。
ISO 32000-1のセクション12.3.5「コレクション」(私はまだ一部2を持っていない)によれば、これは我々が持つビューエントリで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