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 2004/10/10 14:20:56 UTC
cvs commit: xml-fop/src/java/org/apache/fop/svg PDFDocumentGraphics2D.java PDFTranscoder.java
jeremias 2004/10/10 05:20:56
Modified: src/java/org/apache/fop/svg PDFDocumentGraphics2D.java
PDFTranscoder.java
Log:
Implement the cheaper mechanism to ensure correct rendering at differing resolutions. This is probably only an intermediate solution and does not implement what Thomas DeWeese suggested.
Revision Changes Path
1.12 +2 -0 xml-fop/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java
Index: PDFDocumentGraphics2D.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- PDFDocumentGraphics2D.java 22 Apr 2004 21:38:41 -0000 1.11
+++ PDFDocumentGraphics2D.java 10 Oct 2004 12:20:56 -0000 1.12
@@ -62,8 +62,10 @@
private PDFPage currentPage;
private PDFStream pdfStream;
+
private int width;
private int height;
+
private List fontList;
private Log logger;
1.13 +18 -5 xml-fop/src/java/org/apache/fop/svg/PDFTranscoder.java
Index: PDFTranscoder.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/svg/PDFTranscoder.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- PDFTranscoder.java 16 Aug 2004 19:31:41 -0000 1.12
+++ PDFTranscoder.java 10 Oct 2004 12:20:56 -0000 1.13
@@ -27,6 +27,7 @@
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.batik.bridge.BridgeContext;
+import org.apache.batik.bridge.UnitProcessor;
import org.apache.batik.bridge.UserAgent;
import org.apache.batik.gvt.TextPainter;
import org.apache.batik.gvt.renderer.StrokingTextPainter;
@@ -34,6 +35,7 @@
import org.apache.batik.transcoder.TranscoderOutput;
import org.apache.batik.transcoder.image.ImageTranscoder;
import org.w3c.dom.Document;
+import org.w3c.dom.svg.SVGLength;
/**
* This class enables to transcode an input to a pdf document.
@@ -83,8 +85,8 @@
return new AbstractFOPTranscoder.FOPTranscoderUserAgent() {
// The PDF stuff wants everything at 72dpi
public float getPixelUnitToMillimeter() {
- //return super.getPixelUnitToMillimeter();
- return 25.4f / 72; //72dpi = 0.352778f;
+ return super.getPixelUnitToMillimeter();
+ //return 25.4f / 72; //72dpi = 0.352778f;
}
};
}
@@ -126,12 +128,23 @@
getLogger().trace("document size: " + width + " x " + height);
// prepare the image to be painted
- int w = (int)(width + 0.5);
- int h = (int)(height + 0.5);
+ UnitProcessor.Context uctx = UnitProcessor.createContext(ctx,
+ document.getDocumentElement());
+ float widthInPt = UnitProcessor.userSpaceToSVG(width, SVGLength.SVG_LENGTHTYPE_PT,
+ UnitProcessor.HORIZONTAL_LENGTH, uctx);
+ int w = (int)(widthInPt + 0.5);
+ float heightInPt = UnitProcessor.userSpaceToSVG(height, SVGLength.SVG_LENGTHTYPE_PT,
+ UnitProcessor.HORIZONTAL_LENGTH, uctx);
+ int h = (int)(heightInPt + 0.5);
+ getLogger().trace("document size: " + w + "pt x " + h + "pt");
+
+ // prepare the image to be painted
+ //int w = (int)(width + 0.5);
+ //int h = (int)(height + 0.5);
try {
graphics.setupDocument(output.getOutputStream(), w, h);
- graphics.setSVGDimension(w, h);
+ graphics.setSVGDimension(width, height);
if (hints.containsKey(ImageTranscoder.KEY_BACKGROUND_COLOR)) {
graphics.setBackgroundColor
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org