Skip to content

Commit

Permalink
Fix PDF/UA property prefix and improve the bad XML generation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
qligier committed Mar 4, 2021
1 parent 1437eb8 commit 19e9ec7
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,8 @@ private void addPdfASchema(PDDocument document, PdfAConformance pdfAConformance,
XMPSchema pdfUa = createPdfaSchema("PDF/UA Universal Accessibility Schema", "http://www.aiim.org/pdfua/ns/id/", "pdfuaid" , pdfUaProperties);
pdfAExt.addBagValue("schemas", pdfUa);
pdfAExt.addNamespace("http://www.aiim.org/pdfua/ns/id/", "pdfuaid");
pdfAExt.setTextPropertyValue("pdfuaid:part", "1");
pdfAExt.setPrefix("pdfuaid");
pdfAExt.setTextPropertyValue("part", "1");
}

PDMetadata metadataStream = new PDMetadata(document);
Expand All @@ -825,9 +826,8 @@ private void addPdfASchema(PDDocument document, PdfAConformance pdfAConformance,
ByteArrayOutputStream baos = new ByteArrayOutputStream();
serializer.serialize(metadata, baos, true);
String xmp = baos.toString("UTF-8");
// Fixes for bad XML generation
xmp = xmp.replace("lang=", "xml:lang=");
xmp = xmp.replace("pdfaExtension:pdfuaid:part", "pdfuaid:part");
// Fix for bad XML generation by some transformers
xmp = xmp.replace(" lang=\"x-default\"", " xml:lang=\"x-default\"");
metadataStream.importXMPMetadata(xmp.getBytes(StandardCharsets.UTF_8));

if (_colorProfile != null) {
Expand Down

0 comments on commit 19e9ec7

Please sign in to comment.