You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2007/06/22 15:34:39 UTC

svn commit: r549816 - in /xmlgraphics/fop/trunk: ./ lib/ src/java/org/apache/fop/pdf/ test/ test/java/org/apache/fop/render/pdf/ test/xml/pdf-a/

Author: jeremias
Date: Fri Jun 22 06:34:37 2007
New Revision: 549816

URL: http://svn.apache.org/viewvc?view=rev&rev=549816
Log:
Updated PDF/A-1b support according to ISO-19005-1:2005/Cor.1:2007.
Changed test.xconf to match the triplet generated by auto-font-detection (Gladiator is bold) and adjusted PDF/A test files accordingly.
Updated XML Graphics Commons to latest snapshot to include the PDF/A fixes.
Added a unit test for the synchronization of PDF Info and XMP metadata as described in PDF/A-1.

Added:
    xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java   (with props)
Modified:
    xmlgraphics/fop/trunk/lib/xmlgraphics-commons-1.2svn.jar
    xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFMetadata.java
    xmlgraphics/fop/trunk/status.xml
    xmlgraphics/fop/trunk/test/test.xconf
    xmlgraphics/fop/trunk/test/xml/pdf-a/minimal-pdf-a.fo
    xmlgraphics/fop/trunk/test/xml/pdf-a/with-cmyk-images.fo

Modified: xmlgraphics/fop/trunk/lib/xmlgraphics-commons-1.2svn.jar
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/lib/xmlgraphics-commons-1.2svn.jar?view=diff&rev=549816&r1=549815&r2=549816
==============================================================================
Binary files - no diff available.

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFMetadata.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFMetadata.java?view=diff&rev=549816&r1=549815&r2=549816
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFMetadata.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFMetadata.java Fri Jun 22 06:34:37 2007
@@ -34,7 +34,6 @@
 import org.apache.xmlgraphics.xmp.schemas.pdf.AdobePDFAdapter;
 import org.apache.xmlgraphics.xmp.schemas.pdf.AdobePDFSchema;
 import org.apache.xmlgraphics.xmp.schemas.pdf.PDFAAdapter;
-import org.apache.xmlgraphics.xmp.schemas.pdf.PDFAOldXMPSchema;
 import org.apache.xmlgraphics.xmp.schemas.pdf.PDFAXMPSchema;
 
 import org.xml.sax.SAXException;
@@ -136,7 +135,7 @@
             info.setCreationDate(d);
         }
         
-        //Important: Acrobat's preflight check for PDF/A-1b wants the creation date in the Info
+        //Important: Acrobat 7's preflight check for PDF/A-1b wants the creation date in the Info
         //object and in the XMP metadata to have the same timezone or else it shows a validation
         //error even if the times are essentially equal.
 
@@ -149,7 +148,8 @@
             dc.setTitle(info.getTitle());
         }
         if (info.getSubject() != null) {
-            dc.addSubject(info.getSubject());
+            //Subject maps to dc:description["x-default"] as per ISO-19005-1:2005/Cor.1:2007
+            dc.setDescription(null, info.getSubject());
         }
         dc.addDate(info.getCreationDate());
 
@@ -157,25 +157,22 @@
         PDFAMode pdfaMode = pdfDoc.getProfile().getPDFAMode(); 
         if (pdfaMode.isPDFA1LevelB()) {
             PDFAAdapter pdfa = PDFAXMPSchema.getAdapter(meta);
-            //Create the identification a second time with the old namespace to keep 
-            //Adobe Acrobat happy
-            PDFAAdapter pdfaOld = PDFAOldXMPSchema.getAdapter(meta);
             pdfa.setPart(1);
-            pdfaOld.setPart(1);
             if (pdfaMode == PDFAMode.PDFA_1A) {
                 pdfa.setConformance("A"); //PDF/A-1a
-                pdfaOld.setConformance("A"); //PDF/A-1a
             } else {
                 pdfa.setConformance("B"); //PDF/A-1b
-                pdfaOld.setConformance("B"); //PDF/A-1b
             }
         }
         
         //XMP Basic Schema
         XMPBasicAdapter xmpBasic = XMPBasicSchema.getAdapter(meta);
         xmpBasic.setCreateDate(info.getCreationDate());
-        PDFProfile profile = pdfDoc.getProfile(); 
-        if (profile.isModDateRequired()) {
+        PDFProfile profile = pdfDoc.getProfile();
+        if (info.getModDate() != null) {
+            xmpBasic.setModifyDate(info.getModDate());
+        } else if (profile.isModDateRequired()) {
+            //if modify date is needed but none is in the Info object, use creation date
             xmpBasic.setModifyDate(info.getCreationDate());
         }
         if (info.getCreator() != null) {
@@ -210,14 +207,9 @@
         } else {
             info.setAuthor(null);
         }
-        String[] subjects = dc.getSubjects();
-        //PDF/A-1 defines dc:subject as "Text" but XMP defines it as "bag Text".
-        //We're simply doing the inverse from createXMPFromUserAgent() above.
-        if (subjects != null && subjects.length > 0) {
-            info.setSubject(subjects[0]);
-        } else {
-            info.setSubject(null);
-        }
+        
+        //dc:description["x-default"] maps to Subject as per ISO-19005-1:2005/Cor.1:2007
+        info.setSubject(dc.getDescription());
         
         AdobePDFAdapter pdf = AdobePDFSchema.getAdapter(meta);
         info.setKeywords(pdf.getKeywords());

Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?view=diff&rev=549816&r1=549815&r2=549816
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Fri Jun 22 06:34:37 2007
@@ -28,6 +28,9 @@
 
   <changes>
     <release version="FOP Trunk">
+      <action context="Code" dev="JM" type="update">
+        Updated PDF/A-1b support according to ISO-19005-1:2005/Cor.1:2007.
+      </action>
       <action context="Code" dev="JM" type="add" fixes-bug="41831" due-to="Adrian Cumiskey">
         Add support for font auto-detection (easier font configuration).
       </action>

Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java?view=auto&rev=549816
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java (added)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java Fri Jun 22 06:34:37 2007
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.pdf;
+
+import java.util.Calendar;
+import java.util.TimeZone;
+
+import org.apache.fop.pdf.PDFDocument;
+import org.apache.fop.pdf.PDFInfo;
+import org.apache.fop.pdf.PDFMetadata;
+import org.apache.xmlgraphics.xmp.Metadata;
+import org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter;
+import org.apache.xmlgraphics.xmp.schemas.DublinCoreSchema;
+import org.apache.xmlgraphics.xmp.schemas.XMPBasicAdapter;
+import org.apache.xmlgraphics.xmp.schemas.XMPBasicSchema;
+import org.apache.xmlgraphics.xmp.schemas.pdf.AdobePDFAdapter;
+import org.apache.xmlgraphics.xmp.schemas.pdf.AdobePDFSchema;
+
+import junit.framework.TestCase;
+
+/**
+ * Test case for PDF/A metadata handling.
+ */
+public class PDFAMetadataTestCase extends TestCase {
+
+    public void testInfoUpdate() throws Exception {
+        Metadata meta = new Metadata();
+        DublinCoreAdapter dc = DublinCoreSchema.getAdapter(meta);
+        dc.setTitle("MyTitle");
+        dc.setDescription(null, "MySubject");
+        dc.addCreator("That's me");
+        
+        AdobePDFAdapter pdf = AdobePDFSchema.getAdapter(meta);
+        pdf.setKeywords("XSL-FO XML");
+        pdf.setProducer("SuperFOP");
+        
+        XMPBasicAdapter xmp = XMPBasicSchema.getAdapter(meta);
+        xmp.setCreatorTool("WonderFOP");
+        Calendar cal1 = Calendar.getInstance(TimeZone.getTimeZone("Europe/Zurich"));
+        cal1.set(2007, Calendar.JUNE, 5, 21, 49, 13);
+        cal1.set(Calendar.MILLISECOND, 0);
+        xmp.setCreateDate(cal1.getTime());
+        Calendar cal2 = Calendar.getInstance(TimeZone.getTimeZone("Europe/Zurich"));
+        cal2.set(2007, Calendar.JUNE, 6, 8, 15, 59);
+        cal2.set(Calendar.MILLISECOND, 0);
+        xmp.setModifyDate(cal2.getTime());
+        
+        PDFInfo info = new PDFInfo();
+        assertNull(info.getTitle());
+        PDFMetadata.updateInfoFromMetadata(meta, info);
+        
+        assertEquals("MyTitle", info.getTitle());
+        assertEquals("MySubject", info.getSubject());
+        assertEquals("That's me", info.getAuthor());
+        assertEquals("XSL-FO XML", info.getKeywords());
+        assertEquals("SuperFOP", info.getProducer());
+        assertEquals("WonderFOP", info.getCreator());
+        assertEquals(cal1.getTime(), info.getCreationDate());
+        assertEquals(cal2.getTime(), info.getModDate());
+    }
+    
+    public void testXMPUpdate() throws Exception {
+        PDFDocument doc = new PDFDocument("SuperFOP");
+        PDFInfo info = doc.getInfo();
+        info.setTitle("MyTitle");
+        info.setSubject("MySubject");
+        info.setAuthor("That's me");
+        info.setKeywords("XSL-FO XML");
+        //info.setProducer("SuperFOP");
+        info.setCreator("WonderFOP");
+        Calendar cal1 = Calendar.getInstance(TimeZone.getTimeZone("Europe/Zurich"));
+        cal1.set(2007, Calendar.JUNE, 5, 21, 49, 13);
+        cal1.set(Calendar.MILLISECOND, 0);
+        info.setCreationDate(cal1.getTime());
+        Calendar cal2 = Calendar.getInstance(TimeZone.getTimeZone("Europe/Zurich"));
+        cal2.set(2007, Calendar.JUNE, 6, 8, 15, 59);
+        cal2.set(Calendar.MILLISECOND, 0);
+        info.setModDate(cal2.getTime());
+        
+        Metadata meta = PDFMetadata.createXMPFromUserAgent(doc);
+        
+        DublinCoreAdapter dc = DublinCoreSchema.getAdapter(meta);
+        assertEquals("MyTitle", dc.getTitle());
+        assertEquals("MySubject", dc.getDescription());
+        assertEquals(1, dc.getCreators().length);
+        assertEquals("That's me", dc.getCreators()[0]);
+        AdobePDFAdapter pdf = AdobePDFSchema.getAdapter(meta);
+        assertEquals("XSL-FO XML", pdf.getKeywords());
+        assertEquals("SuperFOP", pdf.getProducer());
+        XMPBasicAdapter xmp = XMPBasicSchema.getAdapter(meta);
+        assertEquals("WonderFOP", xmp.getCreatorTool());
+        assertEquals(cal1.getTime(), xmp.getCreateDate());
+        assertEquals(cal2.getTime(), xmp.getModifyDate());
+    }
+}

Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFAMetadataTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/trunk/test/test.xconf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/test.xconf?view=diff&rev=549816&r1=549815&r2=549816
==============================================================================
--- xmlgraphics/fop/trunk/test/test.xconf (original)
+++ xmlgraphics/fop/trunk/test/test.xconf Fri Jun 22 06:34:37 2007
@@ -9,12 +9,15 @@
       <fonts>
         <font metrics-url="test/resources/fonts/glb12.ttf.xml" embed-url="test/resources/fonts/glb12.ttf">
           <font-triplet name="Gladiator" style="normal" weight="normal"/>
+          <font-triplet name="Gladiator" style="normal" weight="bold"/>
         </font>
         <font metrics-url="test/resources/fonts/glb12.ttf.ansi.xml" embed-url="test/resources/fonts/glb12.ttf">
           <font-triplet name="Gladiator-Ansi" style="normal" weight="normal"/>
+          <font-triplet name="Gladiator-Ansi" style="normal" weight="bold"/>
         </font>
         <font metrics-url="test/resources/fonts/glb12.ttf.ansi.xml">
           <font-triplet name="Gladiator-Non-Embedded" style="normal" weight="normal"/>
+          <font-triplet name="Gladiator-Non-Embedded" style="normal" weight="bold"/>
         </font>
       </fonts>
     </renderer>

Modified: xmlgraphics/fop/trunk/test/xml/pdf-a/minimal-pdf-a.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/xml/pdf-a/minimal-pdf-a.fo?view=diff&rev=549816&r1=549815&r2=549816
==============================================================================
--- xmlgraphics/fop/trunk/test/xml/pdf-a/minimal-pdf-a.fo (original)
+++ xmlgraphics/fop/trunk/test/xml/pdf-a/minimal-pdf-a.fo Fri Jun 22 06:34:37 2007
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="Gladiator">
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="Gladiator" font-weight="bold">
   <fo:layout-master-set>
     <fo:simple-page-master master-name="A4" page-height="29.7cm" page-width="21cm" margin="2cm">
       <fo:region-body/>

Modified: xmlgraphics/fop/trunk/test/xml/pdf-a/with-cmyk-images.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/xml/pdf-a/with-cmyk-images.fo?view=diff&rev=549816&r1=549815&r2=549816
==============================================================================
--- xmlgraphics/fop/trunk/test/xml/pdf-a/with-cmyk-images.fo (original)
+++ xmlgraphics/fop/trunk/test/xml/pdf-a/with-cmyk-images.fo Fri Jun 22 06:34:37 2007
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="Gladiator">
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="Gladiator" font-weight="bold">
   <fo:layout-master-set>
     <fo:simple-page-master master-name="A4" page-height="29.7cm" page-width="21cm" margin="2cm">
       <fo:region-body/>



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org