Search code examples
javapdfboxpdfaacrofields

PDF/A validation


I am trying to validate a self created PDF file against the PDF/A-1b specification but I am getting below errors (For the validation I used the Apache PDFBox Preflight library. The version for Apache PDFBox and Preflight is 2.0.15)

3.1.1 : Invalid Font definition, Helvetica: some required fields are missing from the Font dictionary: firstChar, lastChar, widths.

3.1.3 : Invalid Font definition, Helvetica: FontFile entry is missing from FontDescriptor

3.1.1 : Invalid Font definition, ZapfDingbats: some required fields are missing from the Font dictionary: firstChar, lastChar, widths.

3.1.3 : Invalid Font definition, ZapfDingbats: FontFile entry is missing from FontDescriptor

7.11.1 : Error on MetaData

How can I overcome above problems. Thank you in advance

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");

Solution

  • The font related messages are because you used the standard 14 type 1 font objects, e.g. PDType1Font.HELVETICA. PDF/A-1b requires all fonts to be embedded. Thus use PDType0Font.load() to load your fonts. For acroform fields, make sure to use a method that has the third parameter false to prevent subsetting.

    The XMP related messages are because you forgot to set the conformance to "B". See also CreatePDFA.java in the examples subproject of the source code download.