[英]Can the adding of xmp:ModifyDate be avoided in itext7?
当使用itext7从头开始创建PDF / A时,总是将以下内容添加到XMP元数据中:
<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">
我需要明确地不设置xmp: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?
我将向您展示两种避免将ModifyDate
添加到元数据的方法。
第一个,如果在关闭文档之前通过PdfDocumentInfo
:
doc.getDocumentInfo().setMoreInfo(PdfName.ModDate.getValue(), null);
doc.close();
第二种方法更加灵活,可以通过重写PdfDocument
/ PdfADocument
updateXmpMetadata
方法来PdfADocument
:
@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) {
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.