diff options
Diffstat (limited to 'src/java/org/apache/fop/pdf')
-rw-r--r-- | src/java/org/apache/fop/pdf/PDFMetadata.java | 11 | ||||
-rw-r--r-- | src/java/org/apache/fop/pdf/PDFRoot.java | 20 |
2 files changed, 28 insertions, 3 deletions
diff --git a/src/java/org/apache/fop/pdf/PDFMetadata.java b/src/java/org/apache/fop/pdf/PDFMetadata.java index 067502986..e0833a30f 100644 --- a/src/java/org/apache/fop/pdf/PDFMetadata.java +++ b/src/java/org/apache/fop/pdf/PDFMetadata.java @@ -25,6 +25,8 @@ import java.util.Date; import javax.xml.transform.TransformerConfigurationException; +import org.xml.sax.SAXException; + import org.apache.xmlgraphics.xmp.Metadata; import org.apache.xmlgraphics.xmp.XMPSerializer; import org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter; @@ -36,8 +38,6 @@ import org.apache.xmlgraphics.xmp.schemas.pdf.AdobePDFSchema; import org.apache.xmlgraphics.xmp.schemas.pdf.PDFAAdapter; import org.apache.xmlgraphics.xmp.schemas.pdf.PDFAXMPSchema; -import org.xml.sax.SAXException; - /** * Special PDFStream for Metadata. * @since PDF 1.4 @@ -118,10 +118,11 @@ public class PDFMetadata extends PDFStream { * @param pdfDoc the PDF Document * @return the requested XMP metadata */ - public static Metadata createXMPFromUserAgent(PDFDocument pdfDoc) { + public static Metadata createXMPFromPDFDocument(PDFDocument pdfDoc) { Metadata meta = new Metadata(); PDFInfo info = pdfDoc.getInfo(); + PDFRoot root = pdfDoc.getRoot(); //Set creation date if not available, yet if (info.getCreationDate() == null) { @@ -145,6 +146,10 @@ public class PDFMetadata extends PDFStream { //Subject maps to dc:description["x-default"] as per ISO-19005-1:2005/Cor.1:2007 dc.setDescription(null, info.getSubject()); } + if (root.getLanguage() != null) { + //Note: No check is performed to make sure the value is valid RFC 3066! + dc.addLanguage(root.getLanguage()); + } dc.addDate(info.getCreationDate()); //PDF/A identification diff --git a/src/java/org/apache/fop/pdf/PDFRoot.java b/src/java/org/apache/fop/pdf/PDFRoot.java index 54cadf616..0dd9b890c 100644 --- a/src/java/org/apache/fop/pdf/PDFRoot.java +++ b/src/java/org/apache/fop/pdf/PDFRoot.java @@ -232,4 +232,24 @@ public class PDFRoot extends PDFDictionary { } } + /** + * Returns the language identifier of the document. + * @return the language identifier of the document (or null if not set or undefined) + * @since PDF 1.4 + */ + public String getLanguage() { + return (String)get("Lang"); + } + + /** + * Sets the language identifier of the document. + * @param lang the language identifier of the document. + */ + public void setLanguage(String lang) { + if (lang == null) { + throw new NullPointerException("lang must not be null"); + } + put("Lang", lang); + } + } |