Preflight (version 2.0.15) tool has validated correctly the generated pdf (was created with pdfbox version 2.0.15) file but online pdf-tools (e.x. https://www.pdf-online.com/osa/validate.aspx) does not validate it correctly. I am getting below error:
Compliance pdfa-1b Result Document does not conform to PDF/A. Details Validating file "file.pdf" for conformance level pdfa-1b
Anonymous RDF resources (rdf:Description without rdf:about attribute) are not allowed in XMP Metadata.
The appearance dictionary doesn't contain an entry.
The appearance dictionary doesn't contain an entry.
The appearance dictionary doesn't contain an entry.
The appearance dictionary doesn't contain an entry.
The appearance dictionary doesn't contain an entry.
The document does not conform to the requested standard.
The document contains annotations or form fields with ambigous or without appropriate appearances.
The document's meta data is either missing or inconsistent or corrupt. The document does not conform to the PDF/A-1b standard.
Done.
In order to generate metadata I use below code:
private void addMetadata(PDDocument pdDocument,final String zzz,final String yyy) {
PDDocumentCatalog catalog = pdDocument.getDocumentCatalog();
PDDocumentInformation info = pdDocument.getDocumentInformation();
info.setCreationDate(Calendar.getInstance());
info.setModificationDate(Calendar.getInstance());
info.setAuthor(metadataAuthor);
info.setProducer(metadataProducer);
info.setTitle(zzz + "_" + yyy);
info.setKeywords("aaa");
info.setCreator("aaa");
info.setSubject("aaa");
PDMarkInfo markInfo = new PDMarkInfo();
markInfo.setMarked(true);
catalog.setMarkInfo(markInfo);
try {
PDMetadata metadataStream = new PDMetadata(pdDocument);
catalog.setMetadata( metadataStream );
XMPMetadata xmp = new XMPMetadata();
XMPSchemaPDFAId pdfaid = new XMPSchemaPDFAId(xmp);
xmp.addSchema(pdfaid);
pdfaid.setConformance("B");
pdfaid.setPart(1);
pdfaid.setAbout("");
XMPSchemaDublinCore dcSchema = xmp.addDublinCoreSchema();
dcSchema.setTitle( info.getTitle() );
dcSchema.addCreator("aaa");
dcSchema.setDescription( info.getSubject() );
XMPSchemaPDF pdfSchema = xmp.addPDFSchema();
pdfSchema.setKeywords( info.getKeywords() );
pdfSchema.setProducer( info.getProducer() );
XMPSchemaBasic basicSchema = xmp.addBasicSchema();
basicSchema.setModifyDate( info.getModificationDate() );
basicSchema.setCreateDate( info.getCreationDate() );
basicSchema.setCreatorTool( info.getCreator() );
metadataStream.importXMPMetadata(xmp.asByteArray());
InputStream colorProfile = getClass().getClassLoader().getResourceAsStream("icm/sRGB Color Space Profile.icm");
// create output intent
PDOutputIntent oi = new PDOutputIntent(pdDocument, colorProfile);
String value = "sRGB IEC61966-2.1";
oi.setInfo(value);
oi.setOutputCondition(value);
oi.setOutputConditionIdentifier(value);
oi.setRegistryName("http://www.color.org");
catalog.addOutputIntent(oi);
} catch (Exception e) {
e.printStackTrace()
}
}
Any suggestions?
As discussed in the comments:
1) The failure to report "The appearance dictionary doesn't contain an entry" is a bug in PDFBox preflight that will be fixed in 2.0.17, see PDFBOX-4586. According to this document:
An ISO 19005-1 validator shall FAIL otherwise conforming files in which a widget annotation lacks an appearance dictionary
2) The "rdf:Description without rdf:about attribute" may or may not be a bug. VeraPDF doesn't consider it to be one. Your code used an 1.8.* version. For these, you can call dcSchema.setAbout("")
to fix this. In 2.0.* the problem doesn't occur if you created the schema with metadata.createAndAddDublinCoreSchema()
.
I have created an issue in the VeraPDF project and they will bring this question for discussion at the next meeting of the Validation technical working group.
3) That the widgets didn't contain an entry is because at the time setValue()
was called, not enough information was present (e.g. the rectangle).That is why you got the message widget of field aa has no rectangle, no appearance stream created
.