]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
workaround for a bug in Acrobat Reader where text may disappear or
authorKeiron Liddle <keiron@apache.org>
Mon, 25 Jun 2001 14:15:45 +0000 (14:15 +0000)
committerKeiron Liddle <keiron@apache.org>
Mon, 25 Jun 2001 14:15:45 +0000 (14:15 +0000)
be placed in the wrong position

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

src/org/apache/fop/render/pdf/PDFRenderer.java

index 648b880ad379ad99f36c1ef7dc546e45e9a21e69..e9d7e4c83621630c00833b072b015c8a79945e29 100644 (file)
@@ -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;