【问题标题】:PDF/A validationPDF/A 验证
【发布时间】:2019-06-27 09:21:32
【问题描述】:

我正在尝试根据 PDF/A-1b 规范验证自行创建的 PDF 文件,但出现以下错误(对于验证,我使用了 Apache PDFBox Preflight 库。Apache PDFBox 和 Preflight 的版本是 2.0.15 )

3.1.1:字体定义无效,Helvetica:字体字典中缺少一些必填字段:firstChar、lastChar、widths。

3.1.3:字体定义无效,Helvetica:FontDescriptor 中缺少 FontFile 条目

3.1.1:字体定义无效,ZapfDingbats:字体字典中缺少一些必填字段:firstChar、lastChar、widths。

3.1.3:无效的字体定义,ZapfDingbats:FontDescriptor 中缺少 FontFile 条目

7.11.1:元数据错误

我怎样才能克服上述问题。 提前谢谢你

PDResources resources = new PDResources();
resources.put(COSName.getPDFName("Helv"), 
pdfPage.getText1Font());
String deafultAppearance = "/Helv 12 Tf 0 g";

form.setDefaultResources(resources);
form.setDefaultAppearance(deafultAppearance);
pdDocument.getDocumentCatalog().setAcroForm(form);


   metadata.createAndAddPDFAExtensionSchemaWithDefaultNS(); 
 metadata.getPDFExtensionSchema().addNamespace("http://www.aiim.org/pdfa/ns/schema#", "pdfaSchema");
                 metadata.getPDFExtensionSchema().addNamespace("http://www.aiim.org/pdfa/ns/property#", "pdfaProperty");
                metadata.getPDFExtensionSchema().addNamespace("http://www.aiim.org/pdfa/ns/id/", "pdfaid");
    XMPSchema uaSchema = new XMPSchema(XMPMetadata.createXMPMetadata(),
                        "pdfaSchema", "pdfaSchema", "pdfaSchema");
    uaSchema.setTextPropertyValue("schema", "PDF/A Accessibility Schema");
    uaSchema.setTextPropertyValue("namespaceURI", "http://www.aiim.org/pdfa/ns/id/");
                uaSchema.setTextPropertyValue("prefix", "pdfaid");
    XMPSchema uaProp = new XMPSchema(XMPMetadata.createXMPMetadata(),
                        "pdfaProperty", "pdfaProperty", "pdfaProperty");
    uaProp.setTextPropertyValue("name", "part");
    uaProp.setTextPropertyValue("valueType", "Integer");
    uaProp.setTextPropertyValue("category", "internal");
    uaProp.setTextPropertyValue("description", "Indicates, which part of ISO 14289 standard is followed");
    uaSchema.addUnqualifiedSequenceValue("property", uaProp);
    metadata.getPDFExtensionSchema().addBagValue("schemas", uaSchema);
    metadata.getPDFExtensionSchema().setPrefix("pdfaid");
    metadata.getPDFExtensionSchema().setTextPropertyValue("part", "1");

【问题讨论】:

  • 请分享有问题的pdf。
  • 您完全自己创建了文件吗?另请参阅源代码下载中的CreatePDFA.java 示例。
  • 是的,我完全自己创建了文件。我已经看过 CreatePDFA.java。
  • 最初的错误消息表明您没有嵌入字体。在 XMP 代码中,我错过了一致性(“B”)。
  • 我如何正确嵌入?

标签: java pdfbox pdfa acrofields


【解决方案1】:

字体相关消息是因为您使用了标准的 14 种类型 1 字体对象,例如PDType1Font.HELVETICA。 PDF/A-1b 要求嵌入所有字体。因此使用PDType0Font.load() 来加载你的字体。对于 acroform 字段,请确保使用具有第三个参数 false 的方法以防止子集化。

XMP 相关消息是因为您忘记将一致性设置为“B”。另见源代码下载的示例子项目中的CreatePDFA.java

【讨论】:

    猜你喜欢
    • 2023-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-12
    • 1970-01-01
    • 1970-01-01
    • 2014-06-27
    相关资源
    最近更新 更多