]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Enable fox:conversion-mode="bitmap" for PDF output.
authorJeremias Maerki <jeremias@apache.org>
Fri, 22 Apr 2011 06:55:48 +0000 (06:55 +0000)
committerJeremias Maerki <jeremias@apache.org>
Fri, 22 Apr 2011 06:55:48 +0000 (06:55 +0000)
Release memory from Batik GVT as early as possible to break some peaks.

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

src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java
src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java

index d309a00aad48864c291480e788485e6b97e21ea4..a71ade91100cacaf97239a727aee38bba9b81d5a 100644 (file)
@@ -31,6 +31,7 @@ import org.apache.xmlgraphics.image.loader.ImageFlavor;
 import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D;
 
 import org.apache.fop.render.AbstractImageHandlerGraphics2D;
+import org.apache.fop.render.ImageHandlerUtil;
 import org.apache.fop.render.RenderingContext;
 import org.apache.fop.render.pdf.PDFLogicalStructureHandler.MarkedContentInfo;
 import org.apache.fop.svg.PDFGraphics2D;
@@ -60,8 +61,8 @@ public class PDFImageHandlerGraphics2D extends AbstractImageHandlerGraphics2D {
         float imw = (float)dim.getWidth() / 1000f;
         float imh = (float)dim.getHeight() / 1000f;
 
-        float sx = fwidth / (float)imw;
-        float sy = fheight / (float)imh;
+        float sx = fwidth / imw;
+        float sy = fheight / imh;
 
         generator.comment("G2D start");
         boolean accessibilityEnabled = context.getUserAgent().isAccessibilityEnabled();
@@ -123,8 +124,16 @@ public class PDFImageHandlerGraphics2D extends AbstractImageHandlerGraphics2D {
 
     /** {@inheritDoc} */
     public boolean isCompatible(RenderingContext targetContext, Image image) {
-        return (image == null || image instanceof ImageGraphics2D)
+        boolean supported = (image == null || image instanceof ImageGraphics2D)
                 && targetContext instanceof PDFRenderingContext;
+        if (supported) {
+            String mode = (String)targetContext.getHint(ImageHandlerUtil.CONVERSION_MODE);
+            if (ImageHandlerUtil.isConversionModeBitmap(mode)) {
+                //Disabling this image handler automatically causes a bitmap to be generated
+                return false;
+            }
+        }
+        return supported;
     }
 
 }
index d47142fb6686ed2b79729a067c9b5b736c7d2804..2b02b60fb5ebb36f2805120bb0c2ce79d8cc7188 100644 (file)
@@ -43,6 +43,7 @@ import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.image.loader.batik.BatikImageFlavors;
 import org.apache.fop.image.loader.batik.BatikUtil;
 import org.apache.fop.render.ImageHandler;
+import org.apache.fop.render.ImageHandlerUtil;
 import org.apache.fop.render.RenderingContext;
 import org.apache.fop.render.pdf.PDFLogicalStructureHandler.MarkedContentInfo;
 import org.apache.fop.svg.PDFAElementBridge;
@@ -200,6 +201,7 @@ public class PDFImageHandlerSVG implements ImageHandler {
         graphics.setOutputStream(generator.getOutputStream());
         try {
             root.paint(graphics);
+            ctx.dispose();
             generator.add(graphics.getString());
         } catch (Exception e) {
             SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
@@ -236,10 +238,18 @@ public class PDFImageHandlerSVG implements ImageHandler {
 
     /** {@inheritDoc} */
     public boolean isCompatible(RenderingContext targetContext, Image image) {
-        return (image == null
+        boolean supported = (image == null
                 || (image instanceof ImageXMLDOM
                         && image.getFlavor().isCompatible(BatikImageFlavors.SVG_DOM)))
                 && targetContext instanceof PDFRenderingContext;
+        if (supported) {
+            String mode = (String)targetContext.getHint(ImageHandlerUtil.CONVERSION_MODE);
+            if (ImageHandlerUtil.isConversionModeBitmap(mode)) {
+                //Disabling this image handler automatically causes a bitmap to be generated
+                return false;
+            }
+        }
+        return supported;
     }
 
 }