Reputation: 1831
The PAC 2024 Validation Tool, give me that error.
Metadata: PDF/UA identifier is missing
I use
org.apache.pdfbox:pdfbox:3.0.2
How can I set the identifier to a PDDocument?
Upvotes: 0
Views: 221
Reputation: 18956
// file from https://taggedpdf.com/xmp/pdfUA-ID.xmp
try (InputStream is = new FileInputStream(new File("pdfUA-ID.xmp")))
{
XMPMetadata xmp = XMPMetadata.load(is);
xmp.addDublinCoreSchema();
XMPSchemaDublinCore dc = xmp.getDublinCoreSchema();
dc.setTitle("Title");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
xmp.save(baos);
PDMetadata meta = new PDMetadata(doc, new ByteArrayInputStream(baos.toByteArray()));
doc.getDocumentCatalog().setMetadata(meta);
}
this one uses jempbox because xmpbox fails with that schema
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>jempbox</artifactId>
<version>1.8.17</version>
</dependency>
Upvotes: 0