diff options
author | Jeremias Maerki <jeremias@apache.org> | 2011-10-15 10:32:15 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2011-10-15 10:32:15 +0000 |
commit | 87f892d9d8b3e6459e19538156a70632a1bb4e6f (patch) | |
tree | ce71188530503cdc6056c8d9211f8f794b6ddfad /src | |
parent | 25d268f166c66aa8ac5ffb102ab49ec9f88d667c (diff) | |
download | xmlgraphics-fop-87f892d9d8b3e6459e19538156a70632a1bb4e6f.tar.gz xmlgraphics-fop-87f892d9d8b3e6459e19538156a70632a1bb4e6f.zip |
Restored PDFDocumentGraphics2D functionality.
Bugfix: NPE after PDFDocumentGraphics2D.create() due to missing font setup and other missing initializations.
Bugfix: Properly handle state in PDFGraphics2D.drawString().
Added an example class demonstrating the use of PDFDocumentGraphics2D.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1183620 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r-- | src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java | 4 | ||||
-rw-r--r-- | src/java/org/apache/fop/svg/PDFGraphics2D.java | 16 |
2 files changed, 14 insertions, 6 deletions
diff --git a/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java b/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java index 829d8972d..f8f14cca2 100644 --- a/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java +++ b/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java @@ -276,6 +276,7 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D { } /** {@inheritDoc} */ + @Override protected void preparePainting() { if (pdfContext.isPagePending()) { return; @@ -391,7 +392,9 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D { * @return a new graphics context that is a copy of * this graphics context. */ + @Override public Graphics create() { + preparePainting(); return new PDFDocumentGraphics2D(this); } @@ -403,6 +406,7 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D { * @param x the x position * @param y the y position */ + @Override public void drawString(String s, float x, float y) { if (super.textAsShapes) { Font font = super.getFont(); diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java index 4ae8e72d7..0d25e166c 100644 --- a/src/java/org/apache/fop/svg/PDFGraphics2D.java +++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java @@ -751,10 +751,14 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand } boolean doWrite = false; - if (fill && paintingState.setBackColor(col)) { - doWrite = true; - } else if (paintingState.setColor(col)) { - doWrite = true; + if (fill) { + if (paintingState.setBackColor(col)) { + doWrite = true; + } + } else { + if (paintingState.setColor(col)) { + doWrite = true; + } } if (doWrite) { StringBuffer sb = new StringBuffer(); @@ -1327,7 +1331,7 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand } updateCurrentFont(fontState); - currentStream.write("q\n"); + saveGraphicsState(); Color c = getColor(); applyColor(c, true); @@ -1402,7 +1406,7 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand currentStream.write("] TJ\n"); currentStream.write("ET\n"); - currentStream.write("Q\n"); + restoreGraphicsState(); } /** |