From e2f5099ed6725379d33be6bfb0ca517c621cea84 Mon Sep 17 00:00:00 2001 From: Keiron Liddle Date: Mon, 25 Jun 2001 14:15:45 +0000 Subject: [PATCH] workaround for a bug in Acrobat Reader where text may disappear or be placed in the wrong position git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194316 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/render/pdf/PDFRenderer.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/org/apache/fop/render/pdf/PDFRenderer.java b/src/org/apache/fop/render/pdf/PDFRenderer.java index 648b880ad..e9d7e4c83 100644 --- a/src/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/org/apache/fop/render/pdf/PDFRenderer.java @@ -374,7 +374,6 @@ public class PDFRenderer extends PrintRenderer { GraphicsNodeRenderContext rc = getRenderContext(); BridgeContext ctx = new BridgeContext(userAgent, rc); GraphicsNode root; - //System.out.println("creating PDFGraphics2D"); PDFGraphics2D graphics = new PDFGraphics2D(true, fs, pdfDoc, currentFontName, currentFontSize, currentXPosition, @@ -387,7 +386,7 @@ public class PDFRenderer extends PrintRenderer { root.paint(graphics, rc); currentStream.add(graphics.getString()); } catch (Exception e) { - e.printStackTrace(); + MessageHandler.errorln("Error: svg graphic could not be rendered: " + e.getMessage()); } currentStream.add("Q\n"); @@ -408,6 +407,7 @@ public class PDFRenderer extends PrintRenderer { true); TextPainter textPainter = new StrokingTextPainter(); + //TextPainter textPainter = new PDFTextPainter(); GraphicsNodeRableFactory gnrFactory = new ConcreteGraphicsNodeRableFactory(); @@ -499,9 +499,19 @@ public class PDFRenderer extends PrintRenderer { int space = prevWordX - rx + prevWordWidth; float emDiff = (float) space / (float) currentFontSize * 1000f; - pdf.append(Float.toString(emDiff)); - pdf.append(" "); - pdf.append(startText); + // this prevents a problem in Acrobat Reader where large + // numbers cause text to disappear or default to a limit + if(emDiff < -33000) { + closeText(); + + pdf.append("1 0 0 1 " +(rx / 1000f) + " " + + (bl / 1000f) + " Tm [" + startText); + textOpen = true; + } else { + pdf.append(Float.toString(emDiff)); + pdf.append(" "); + pdf.append(startText); + } } prevWordWidth = area.getContentWidth(); prevWordX = rx; -- 2.39.5