Hi all,

   I've attached a patch for the PDF Transcoder that Batik
uses.  There are three basic parts to the patch.  The first
gives each image added to the PDFGraphics2D a unique key.
Without this the PDF ends up referencing the same image
for each Jpeg added (this is the changes to PDFGraphics2D).

   The second part of the patch adds some additional classes
to the pdf-transcoder jar that are needed for some JPEG images.
It also adds a call to 'load(FopImage.ORIGINAL_DATA, null)' so
that colorspace info is available.  I am not entirely happy with
the location of this call, and I really don't like passing 'null'
as the UA - however I couldn't track down where the UA is available.
This call could/should also be moved into PDFDocument.addImage
or perhaps made internal to FopPDFImage.

   The third part is the removal of 'pdfg.setTransform(...)' from
the primitivePaint method from PDFImageElementBridge.


? diffs
? foUnits.pdf
? pdfDPI.patch
? pdfImage.patch
? pdfJpeg.patch
? pdfTranscoder.patch
Index: build.xml
===================================================================
RCS file: /home/cvs/xml-fop/build.xml,v
retrieving revision 1.99
diff -w -u -r1.99 build.xml
--- build.xml   21 Jan 2004 19:36:39 -0000      1.99
+++ build.xml   22 Jan 2004 01:59:12 -0000
@@ -538,7 +538,10 @@
         <!--include name="org/apache/fop/layout/Font*.class"/-->
         <include name="org/apache/fop/image/FopImag*.class"/>
         <include name="org/apache/fop/image/Jpeg*"/>
+        <include name="org/apache/fop/image/EPS*"/>
         <include name="org/apache/fop/image/Abstract*"/>
+        <include name="org/apache/fop/image/analyser/*.class"/>
+        <include name="org/apache/fop/util/CMYKColorSpace*.class"/>
         <include name="org/apache/fop/util/StreamUtilities.class"/>
         <include name="org/apache/fop/util/*OutputStream.class"/>
         <include name="org/apache/fop/util/Finalizable.class"/>
@@ -598,7 +601,7 @@
       <fileset dir="${build.dest}">
         <patternset refid="transcoder-classes"/>
       </fileset>
-      <fileset dir="${build.dir}/transcoder-dependencies"/>
+      <fileset dir="${transcoder-deps}"/>
       <manifest>
         <attribute name="Implementation-Title" value="${fop-transcoder.name}"/>
         <attribute name="Implementation-Version" value="${fop-transcoder.version}"/>
Index: src/java/org/apache/fop/svg/PDFGraphics2D.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/svg/PDFGraphics2D.java,v
retrieving revision 1.12
diff -w -u -r1.12 PDFGraphics2D.java
--- src/java/org/apache/fop/svg/PDFGraphics2D.java      12 Dec 2003 22:37:39 -0000     
 1.12
+++ src/java/org/apache/fop/svg/PDFGraphics2D.java      22 Jan 2004 01:59:16 -0000
@@ -152,6 +152,12 @@
     protected int baseLevel = 0;
 
     /**
+     * The count of JPEG images added to document so they recieve
+     * unique keys.
+     */
+    protected int jpegCount = 0;
+
+    /**
      * The current font information.
      */
     protected Document fontInfo;
@@ -340,9 +346,13 @@
      * @param width the width to draw the image
      * @param height the height to draw the image
      */
-    public void addJpegImage(JpegImage jpeg, float x, float y, float width, float 
height) {
-        FopPDFImage fopimage = new FopPDFImage(jpeg, "");
-        int xObjectNum = this.pdfDoc.addImage(resourceContext, fopimage).getXNumber();
+    public void addJpegImage(JpegImage jpeg, float x, float y, 
+                             float width, float height) {
+        String key = "__AddJPEG_"+jpegCount;
+        jpegCount++;
+        FopPDFImage fopimage = new FopPDFImage(jpeg, key);
+        int xObjectNum = this.pdfDoc.addImage(resourceContext, 
+                                              fopimage).getXNumber();
 
         AffineTransform at = getTransform();
         double[] matrix = new double[6];
Index: src/java/org/apache/fop/svg/PDFImageElementBridge.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/svg/PDFImageElementBridge.java,v
retrieving revision 1.4
diff -w -u -r1.4 PDFImageElementBridge.java
--- src/java/org/apache/fop/svg/PDFImageElementBridge.java      3 Jan 2004 03:25:02 
-0000       1.4
+++ src/java/org/apache/fop/svg/PDFImageElementBridge.java      22 Jan 2004 01:59:16 
-0000
@@ -97,6 +97,7 @@
                 (purl.toString(), purl.openStream(), null);
             if (ii.mimeType.toLowerCase() == "image/jpeg") {
                 JpegImage jpeg = new JpegImage(ii);
+                jpeg.load(FopImage.ORIGINAL_DATA, null);
                 PDFJpegNode node = new PDFJpegNode(jpeg, origGN);
 
                 Rectangle2D imgBounds = getImageBounds(ctx, e);
@@ -154,7 +155,6 @@
         public void primitivePaint(Graphics2D g2d) {
             if (g2d instanceof PDFGraphics2D) {
                 PDFGraphics2D pdfg = (PDFGraphics2D) g2d;
-                pdfg.setTransform(getTransform());
                 float x = 0;
                 float y = 0;
                 try {
Index: src/java/org/apache/fop/svg/PDFTranscoder.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/svg/PDFTranscoder.java,v
retrieving revision 1.9
diff -w -u -r1.9 PDFTranscoder.java

Reply via email to