Skip to content

Commit

Permalink
Fixes #707 - Add Dublin Core schema to PDF/UA docs.
Browse files Browse the repository at this point in the history
Fixes regression for PDF/UA introduced in #664. Thanks to @syjer for tracking down.

Also add meta subject to PDF/UA samples which is now used as the Dublin Core description.
  • Loading branch information
danfickle committed Jul 12, 2021
1 parent 08b401c commit f22ee82
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<html>
<head>
<title>Simple PDF/UA Bookmarks sample</title>
<meta name="subject" content="PDF/UA bookmarks sample"/>
<style>
@page {
size: A4;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<html lang="EN-US">
<head>
<title>Image over two pages for PDF/UA</title>
<meta name="subject" content="PDF/UA image over two pages sample"/>

<style>
@page {
size: 200px 200px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<html lang="EN-US">
<head>
<title>Image for PDF/UA</title>
<meta name="subject" content="PDF/UA image sample"/>
</head>
<body style="font-family: 'TestFont';">
<img src="../../demos/images/flyingsaucer.png" alt="Sample Image Alt Text: Flyingsaucer"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<html>
<head>
<title>Simple PDF/UA Testcase</title>
<meta name="subject" content="PDF/UA z-index sample"/>
<meta name="description" content="A simple example"/>
<style>
@page {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<head>
<title>Simple PDF/UA Link Testcase</title>
<meta name="description" content="A simple link example"/>
<meta name="subject" content="PDF/UA links sample"/>
<style>
@page {
size: 200px 200px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<head>
<title>Simple PDF/UA List Testcase</title>
<meta name="description" content="A simple list example"/>
<meta name="subject" content="PDF/UA lists sample"/>
<style>
@page {
size: 200px 200px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<head>
<title>Complex PDF/UA Ordering Testcase</title>
<meta name="description" content="A complex ordering example"/>
<meta name="subject" content="PDF/UA complex ordering sample"/>

<style>
@page {
size: 200px 200px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<head>
<title>Simple PDF/UA Testcase</title>
<meta name="description" content="A simple example"/>
<meta name="subject" content="PDF/UA running elements sample"/>
<style>
@page {
size: 200px 200px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<head>
<title>Simple PDF/UA Testcase</title>
<meta name="description" content="A simple example"/>
<meta name="subject" content="PDF/UA simple example"/>

<style>
@page {
size: 200px 200px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<html>
<head>
<title>A title of a document</title>
<meta name="subject" content="PDF/UA simplest example"/>
</head>
<body style="font-family: 'TestFont';">
Word
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<head>
<title>Simple PDF/UA Table Testcase</title>
<meta name="description" content="A simple table example"/>
<meta name="subject" content="PDF/UA tables sample"/>

<style>
@page {
size: 200px 200px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<head>
<title>Simple PDF/UA Testcase</title>
<meta name="description" content="A simple example"/>
<meta name="subject" content="PDF/UA text over two pages sample"/>

<style>
@page {
size: 200px 200px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -754,21 +754,24 @@ private void addPdfASchema(PDDocument document, PdfAConformance pdfAConformance,
if (modDate != null) {
xmpBasicSchema.setModifyDate(modDate);
}
}

DublinCoreSchema dc = metadata.createAndAddDublinCoreSchema();
dc.setFormat("application/pdf");

DublinCoreSchema dc = metadata.createAndAddDublinCoreSchema();
dc.setFormat("application/pdf");
if (author != null) {
dc.addCreator(author);
}
if (title != null) {
dc.setTitle(title);
}
if (subject != null) {
dc.setDescription(subject);
} else if (isPdfUa) {
XRLog.log(Level.WARNING, LogMessageId.LogMessageId0Param.GENERAL_PDF_ACCESSIBILITY_NO_DOCUMENT_DESCRIPTION_PROVIDED);
}
if (author != null) {
dc.addCreator(author);
}

if (title != null) {
dc.setTitle(title);
}

if (subject != null) {
dc.setDescription(subject);
} else if (isPdfUa) {
XRLog.log(Level.WARNING,
LogMessageId.LogMessageId0Param.GENERAL_PDF_ACCESSIBILITY_NO_DOCUMENT_DESCRIPTION_PROVIDED);
}

PDFAExtensionSchema pdfAExt = metadata.createAndAddPDFAExtensionSchemaWithDefaultNS();
Expand Down Expand Up @@ -797,6 +800,7 @@ private void addPdfASchema(PDDocument document, PdfAConformance pdfAConformance,
pdfAExt.addBagValue("schemas",
createPdfaSchema("PDF/A ID Schema", "http://www.aiim.org/pdfa/ns/id/", "pdfaid", pdfaidProperties));
}

if (isPdfUa) {
// Description of PDF/UA
List<XMPSchema> pdfUaProperties = new ArrayList<>(1);
Expand All @@ -817,7 +821,7 @@ private void addPdfASchema(PDDocument document, PdfAConformance pdfAConformance,
PDDocumentCatalog catalog = document.getDocumentCatalog();
catalog.setMetadata(metadataStream);
catalog.setMarkInfo(markInfo);

String lang = _doc.getDocumentElement().getAttribute("lang");
catalog.setLanguage(!lang.isEmpty() ? lang : "EN-US");
catalog.setViewerPreferences(new PDViewerPreferences(new COSDictionary()));
Expand Down

0 comments on commit f22ee82

Please sign in to comment.