]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
The about attribute must have the "rdf" namespace prefix.
authorJeremias Maerki <jeremias@apache.org>
Thu, 23 Mar 2006 09:52:24 +0000 (09:52 +0000)
committerJeremias Maerki <jeremias@apache.org>
Thu, 23 Mar 2006 09:52:24 +0000 (09:52 +0000)
Adobe Acrobat uses an outdated namespace URI for the PDF/A identification, so do the same as Adobe Distiller: write the PDF/A identification twice, once with each namespace URI. Reason: Acrobat is probably the best tool to verify PDF/A conformance right now. jHove covers only part of ISO 19005-1.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@388126 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/fo/extensions/xmp/XMPConstants.java
src/java/org/apache/fop/pdf/PDFMetadata.java

index 6edb1fa41c18d2ab54e66e3d0c16a6f1cb49e7f2..6c4c33fb35e1f9a5e359d087c0ca1cbc26df564e 100644 (file)
@@ -41,4 +41,10 @@ public interface XMPConstants {
     /** Namespace URI for the PDF/A Identification Schema */
     String PDF_A_IDENTIFICATION = "http://www.aiim.org/pdfa/ns/id";
     
+    /**
+     * Namespace URI for the PDF/A Identification Schema
+     * (from an older draft of ISO 19005-1, used by Adobe Acrobat)
+     */
+    String PDF_A_IDENTIFICATION_OLD = "http://www.aiim.org/pdfa/ns/id.html";
+    
 }
index 6aec41ca532d509b33bf1551a9010a0a37cb32a9..13774c0264792fa9092e00c5bf24b1196c43149c 100644 (file)
@@ -45,6 +45,8 @@ import org.w3c.dom.Element;
  */
 public class PDFMetadata extends PDFStream {
     
+    private static final String XMLNS = "http://www.w3.org/2000/xmlns/";
+
     private Document xmpMetadata;
     private boolean readOnly = true;
 
@@ -167,12 +169,10 @@ public class PDFMetadata extends PDFStream {
             info.setCreationDate(d);
         }
 
-        final String xmlns = "http://www.w3.org/2000/xmlns/";
-        
         //Dublin Core
         desc = doc.createElementNS(XMPConstants.RDF_NAMESPACE, "rdf:Description");
-        desc.setAttribute("about", "");
-        desc.setAttributeNS(xmlns, "xmlns:dc", XMPConstants.DUBLIN_CORE_NAMESPACE);
+        desc.setAttributeNS(XMPConstants.RDF_NAMESPACE, "rdf:about", "");
+        desc.setAttributeNS(XMLNS, "xmlns:dc", XMPConstants.DUBLIN_CORE_NAMESPACE);
         rdf.appendChild(desc);
         if (info.getAuthor() != null) {
             el = doc.createElementNS(XMPConstants.DUBLIN_CORE_NAMESPACE, "dc:creator");
@@ -199,8 +199,8 @@ public class PDFMetadata extends PDFStream {
         
         //XMP Basic Schema
         desc = doc.createElementNS(XMPConstants.RDF_NAMESPACE, "rdf:Description");
-        desc.setAttribute("about", "");
-        desc.setAttributeNS(xmlns, "xmlns:xmp", XMPConstants.XMP_BASIC_NAMESPACE);
+        desc.setAttributeNS(XMPConstants.RDF_NAMESPACE, "rdf:about", "");
+        desc.setAttributeNS(XMLNS, "xmlns:xmp", XMPConstants.XMP_BASIC_NAMESPACE);
         rdf.appendChild(desc);
         el = doc.createElementNS(XMPConstants.XMP_BASIC_NAMESPACE, "xmp:createDate");
         desc.appendChild(el);
@@ -213,8 +213,8 @@ public class PDFMetadata extends PDFStream {
         
         //Adobe PDF Schema
         desc = doc.createElementNS(XMPConstants.RDF_NAMESPACE, "rdf:Description");
-        desc.setAttribute("about", "");
-        desc.setAttributeNS(xmlns, "xmlns:pdf", XMPConstants.ADOBE_PDF_NAMESPACE);
+        desc.setAttributeNS(XMPConstants.RDF_NAMESPACE, "rdf:about", "");
+        desc.setAttributeNS(XMLNS, "xmlns:pdf", XMPConstants.ADOBE_PDF_NAMESPACE);
         rdf.appendChild(desc);
         if (info.getKeywords() != null) {
             el = doc.createElementNS(XMPConstants.ADOBE_PDF_NAMESPACE, "pdf:Keywords");
@@ -233,24 +233,36 @@ public class PDFMetadata extends PDFStream {
         //PDF/A identification
         PDFAMode pdfaMode = pdfDoc.getPDFAMode(); 
         if (pdfaMode.isPDFA1LevelB()) {
-            desc = doc.createElementNS(XMPConstants.RDF_NAMESPACE, "rdf:Description");
-            desc.setAttribute("about", "");
-            desc.setAttributeNS(xmlns, "xmlns:pdfaid", XMPConstants.PDF_A_IDENTIFICATION);
-            rdf.appendChild(desc);
-            el = doc.createElementNS(XMPConstants.PDF_A_IDENTIFICATION, "pdfaid:part");
-            desc.appendChild(el);
-            el.appendChild(doc.createTextNode("1")); //PDF/A-1
-            el = doc.createElementNS(XMPConstants.PDF_A_IDENTIFICATION, "pdfaid:conformance");
-            desc.appendChild(el);
-            if (pdfaMode == PDFAMode.PDFA_1A) {
-                el.appendChild(doc.createTextNode("A")); //PDF/A-1a
-            } else {
-                el.appendChild(doc.createTextNode("B")); //PDF/A-1b
-            }
+            createPDFAIndentification(doc, rdf, 
+                    XMPConstants.PDF_A_IDENTIFICATION, "pdfaid", pdfaMode);
+            //Create the identification a second time with the old namespace to keep 
+            //Adobe Acrobat happy
+            createPDFAIndentification(doc, rdf, 
+                    XMPConstants.PDF_A_IDENTIFICATION_OLD, "pdfaid_1", pdfaMode);
         }
         
         return doc;
     }
+
+    private static void createPDFAIndentification(Document doc, Element rdf, 
+            String pdfaNamespace, String prefix, PDFAMode pdfaMode) {
+        Element desc;
+        Element el;
+        desc = doc.createElementNS(XMPConstants.RDF_NAMESPACE, "rdf:Description");
+        desc.setAttributeNS(XMPConstants.RDF_NAMESPACE, "rdf:about", "");
+        desc.setAttributeNS(XMLNS, "xmlns:" + prefix, pdfaNamespace);
+        rdf.appendChild(desc);
+        el = doc.createElementNS(pdfaNamespace, prefix + ":part");
+        desc.appendChild(el);
+        el.appendChild(doc.createTextNode("1")); //PDF/A-1
+        el = doc.createElementNS(pdfaNamespace, prefix + ":conformance");
+        desc.appendChild(el);
+        if (pdfaMode == PDFAMode.PDFA_1A) {
+            el.appendChild(doc.createTextNode("A")); //PDF/A-1a
+        } else {
+            el.appendChild(doc.createTextNode("B")); //PDF/A-1b
+        }
+    }
     
     
 }