Skip to content

Commit

Permalink
Fixes #332 - Don't crash if PDF/UA meta data is not provided.
Browse files Browse the repository at this point in the history
Warn instead.
  • Loading branch information
danfickle committed Mar 2, 2019
1 parent 2cb7216 commit 41d5aa8
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -702,11 +702,17 @@ private void addPdfUaXMPSchema(PDDocument doc) {
catalog.setMarkInfo(markInfo);

PDDocumentInformation info = doc.getDocumentInformation();
String title = info.getTitle() != null ? info.getTitle() : "";

if (title.isEmpty()) {
XRLog.general(Level.WARNING, "No document title provided. Document will not be PDF/UA compliant.");
}

XMPMetadata xmp = XMPMetadata.createXMPMetadata();
xmp.createAndAddDublinCoreSchema();
xmp.getDublinCoreSchema().setTitle(info.getTitle());
xmp.getDublinCoreSchema().setTitle(title);
String metaDescription = _outputDevice.getMetadataByName("description");
xmp.getDublinCoreSchema().setDescription(metaDescription != null ? metaDescription : info.getTitle());
xmp.getDublinCoreSchema().setDescription(metaDescription != null ? metaDescription : title);
xmp.createAndAddPDFAExtensionSchemaWithDefaultNS();
xmp.getPDFExtensionSchema().addNamespace(
"http://www.aiim.org/pdfa/ns/schema#", "pdfaSchema");
Expand Down

0 comments on commit 41d5aa8

Please sign in to comment.