2017-05-13 3 views
0

itext7スクラッチからPDF/Aを作成し、常にXMPメタデータに追加されます以下:私は明示的にXMPを設定しないようにする必要がありますitext7でxmp:ModifyDateの追加を避けることはできますか?

<rdf:Description rdf:about="" 
    xmlns:dc="http://purl.org/dc/elements/1.1/" 
    xmlns:pdf="http://ns.adobe.com/pdf/1.3/" 
    xmlns:pdfaExtension="http://www.aiim.org/pdfa/ns/extension/" 
    xmlns:pdfaSchema="http://www.aiim.org/pdfa/ns/schema#" 
    xmlns:pdfaProperty="http://www.aiim.org/pdfa/ns/property#" 
    xmlns:xmp="http://ns.adobe.com/xap/1.0/" 
    xmlns:pdfuaid="http://www.aiim.org/pdfua/ns/id/" 
    xmlns:pdfaid="http://www.aiim.org/pdfa/ns/id/" 
    dc:format="application/pdf" 
    pdf:Producer="iText® 7.0.3-SNAPSHOT ©2000-2017 iText Group NV (AGPL-version)" 
    xmp:CreateDate="2017-05-09T15:02:05+02:00" 
    xmp:ModifyDate="2017-05-09T15:02:05+02:00" 
    pdfaid:part="2" 
    pdfaid:conformance="A"> 

:ModifyDate。 私はカタログから削除しようとしましたが、無駄に:

PdfADocument pdf = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2A, OutputIntent); 
Document document = new Document(pdf); 
... add content to pdf ... 
pdf.getCatalog().remove(PdfName.ModDate); 
document.close(); 
writer.close(); 

しかし、まだ、XMPは:ModifyDateは、XMPメタデータに表示されます。

xmp:CreateDateだけが追加されていることを確認する方法はありますか?

答えて

1

ModifyDateをメタデータに追加することを回避する2つの方法を示します。

1つがPdfDocumentInfo介して右文書を閉じる前に:

doc.getDocumentInfo().setMoreInfo(PdfName.ModDate.getValue(), null); 
doc.close(); 

方法は、より柔軟であり、PdfDocument/PdfADocumentにオーバーライドupdateXmpMetadata方法を介して行われる:

@Override 
protected void updateXmpMetadata() { 
    // Do not forget to call the method of the base class! 
    super.updateXmpMetadata(); 
    try { 
     XMPMeta meta = XMPMetaFactory.parseFromBuffer(getXmpMetadata(true)); 
     // Here we remove the unwanted entry from the metadata 
     meta.deleteProperty(XMPConst.NS_XMP, PdfConst.ModifyDate); 
     setXmpMetadata(meta); 
    } catch (XMPException e) { 
    } 
} 
+1

Cool、thx Alexey! XMPとDocumentInfoの整合性を保つためには、両方の方法を使用する必要があります: – xormar

+0

@ xormar実際に有効な点です! –

関連する問題