]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugzilla #37330:
authorJeremias Maerki <jeremias@apache.org>
Wed, 9 Nov 2005 15:42:51 +0000 (15:42 +0000)
committerJeremias Maerki <jeremias@apache.org>
Wed, 9 Nov 2005 15:42:51 +0000 (15:42 +0000)
Fix for bridge registration.
Submitted by: Thomas Deweese <deweese.at.apache.org>

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

src/java/org/apache/fop/svg/PDFTranscoder.java

index dba8f84c566db524c6a946faea6a562b8dca888f..d19f75bcfed5960f2c87f1bec9a079cbff5927e3 100644 (file)
@@ -30,8 +30,6 @@ import org.apache.batik.bridge.BridgeContext;
 import org.apache.batik.bridge.UnitProcessor;
 import org.apache.batik.bridge.UserAgent;
 import org.apache.batik.ext.awt.RenderingHintsKeyExt;
-import org.apache.batik.gvt.TextPainter;
-import org.apache.batik.gvt.renderer.StrokingTextPainter;
 import org.apache.batik.transcoder.TranscoderException;
 import org.apache.batik.transcoder.TranscoderOutput;
 import org.apache.batik.transcoder.image.ImageTranscoder;
@@ -69,6 +67,8 @@ public class PDFTranscoder extends AbstractFOPTranscoder
         implements Configurable {
 
     private   Configuration         cfg      = null;
+    
+    /** Graphics2D instance that is used to paint to */
     protected PDFDocumentGraphics2D graphics = null;
 
     /**
@@ -149,10 +149,12 @@ public class PDFTranscoder extends AbstractFOPTranscoder
             if (hints.containsKey(ImageTranscoder.KEY_BACKGROUND_COLOR)) {
                 graphics.setBackgroundColor
                     ((Color)hints.get(ImageTranscoder.KEY_BACKGROUND_COLOR));
-        }
+            }
             graphics.setGraphicContext
                 (new org.apache.batik.ext.awt.g2d.GraphicContext());
-            graphics.setTransform(curTxf);
+            graphics.preparePainting();
+
+            graphics.transform(curTxf);
             graphics.setRenderingHint
                 (RenderingHintsKeyExt.KEY_TRANSCODING,
                  RenderingHintsKeyExt.VALUE_TRANSCODING_VECTOR);
@@ -165,31 +167,49 @@ public class PDFTranscoder extends AbstractFOPTranscoder
         }
     }
 
+    /** @see org.apache.batik.transcoder.SVGAbstractTranscoder#createBridgeContext() */
     protected BridgeContext createBridgeContext() {
-        /*boolean stroke = true;
-        if (hints.containsKey(KEY_STROKE_TEXT)) {
-            stroke = ((Boolean)hints.get(KEY_STROKE_TEXT)).booleanValue();
-        }*/
-
-        BridgeContext ctx = new BridgeContext(userAgent);
-        TextPainter textPainter = null;
-        textPainter = new StrokingTextPainter();
-        ctx.setTextPainter(textPainter);
-        /*if (!stroke) {
-            textPainter = new PDFTextPainter(graphics.getFontInfo());
-            ctx.setTextPainter(textPainter);
-        }*/
-
-        PDFTextElementBridge pdfTextElementBridge;
-        pdfTextElementBridge = new PDFTextElementBridge(graphics.getFontInfo());
-        ctx.putBridge(pdfTextElementBridge);
-
-        PDFAElementBridge pdfAElementBridge = new PDFAElementBridge();
-        AffineTransform currentTransform = new AffineTransform(1, 0, 0, 1, 0, 0);
-        pdfAElementBridge.setCurrentTransform(currentTransform);
-        ctx.putBridge(pdfAElementBridge);
-        ctx.putBridge(new PDFImageElementBridge());
+        BridgeContext ctx = new PDFBridgeContext(userAgent);
+
         return ctx;
     }
 
+    /**
+     * BridgeContext which registers the custom bridges for PDF output.
+     */
+    public class PDFBridgeContext extends BridgeContext {
+        /**
+         * Constructs a new bridge context.
+         * @param userAgent the user agent
+         */
+        public PDFBridgeContext(UserAgent userAgent) {
+            super(userAgent);
+        }
+
+        /** @see org.apache.batik.bridge.BridgeContext#registerSVGBridges() */
+        public void registerSVGBridges() {
+            super.registerSVGBridges();
+
+            /*
+            boolean stroke = true;
+            if (hints.containsKey(KEY_STROKE_TEXT)) {
+                stroke = ((Boolean)hints.get(KEY_STROKE_TEXT)).booleanValue();
+            }
+            if (!stroke) {
+                textPainter = new PDFTextPainter(graphics.getFontInfo());
+                ctx.setTextPainter(textPainter);
+            }
+            */
+
+            putBridge(new PDFTextElementBridge(graphics.getFontInfo()));
+
+            PDFAElementBridge pdfAElementBridge = new PDFAElementBridge();
+            pdfAElementBridge.setCurrentTransform(new AffineTransform());
+            putBridge(pdfAElementBridge);
+
+            putBridge(new PDFImageElementBridge());
+        }
+        
+    }
+
 }