1

添付ファイル付きの iText を使用して PDF/A-3-B (ISO 19005-3:2012. Part 3) を作成する必要があります。

PDF のドキュメント カタログに AF エントリを作成するにはどうすればよいですか?

この質問の最後にある Java コードを使用して、模擬テストを作成しました。Adobe XI Pro Preflight を使用すると、PDF の構造が次のようになっていることがわかります。

The document catalog root
   AF:
      0: (6)   /T:FileSpec

ただし、構造は次のようにする必要があります。

The document catalog root
   AF:
      0: (6) [6 0 R]   /T:FileSpec

つまり、AF エントリは添付ファイル自体へのポインタであるべきだと思います。

ISO は次のように述べています。

KEY:   AF
TYPE:  array of dictionaries
Value: (Optional) An array of File Specification Dictionaries 
       representing the source content from which this document is 
       derived or data used to produce the visual representation.

例を作成するために使用できるモック Java コードは次のとおりです。

public static final String RESULT = "target/pdfa3.pdf";
public static final String FONTPATH = "/usr/share/fonts/truetype/msttcorefonts/times.ttf";
private static Font FONT = FontFactory.getFont(FONTPATH, BaseFont.CP1252, BaseFont.EMBEDDED);

public void test(){
   //creating document
   Document document = new Document();
   PdfAWriter writer = PdfAWriter.getInstance(document, new FileOutputStream(RESULT), PdfAConformanceLevel.PDF_A_3B);

   //creating default Xmp
   writer.createXmpMetadata();

   document.open();

   //adding attachment as embedded file
   PdfDictionary fileParameter = new PdfDictionary();
   fileParameter.put(new PdfName("ModDate"), new PdfString("2013-01-09T16:28-02:00"));
   PdfFileSpecification fs = PdfFileSpecification.fileEmbedded(writer, src.getAbsolutePath(), src.getName(), null, false, "image/jpeg", fileParameter);
   fs.put(new PdfName("AFRelationship"), new PdfName("Source"));
   writer.addFileAttachment(src.getName().substring(0, src.getName().indexOf('.')), fs);

   //???????????????????
   //THIS IS THE POINT: HOW TO ADD AN AF ENTRY?
   //this does not work:
   writer.getExtraCatalog().put(new PdfName("AF"), new PdfArray(fs));
   //???????????????????

   //adding some text
   document.add(new Paragraph("Hello World!", FONT));

   //done!
   document.close();
}
4

0 に答える 0