diff options
Diffstat (limited to 'src/java/org/apache/fop/svg/PDFGraphics2D.java')
-rw-r--r-- | src/java/org/apache/fop/svg/PDFGraphics2D.java | 44 |
1 files changed, 12 insertions, 32 deletions
diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java index ca2245a12..0b2f0a45f 100644 --- a/src/java/org/apache/fop/svg/PDFGraphics2D.java +++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java @@ -440,6 +440,14 @@ public class PDFGraphics2D extends AbstractGraphics2D { } PDFXObject xObject = this.pdfDoc.addImage(resourceContext, pdfImage); + flushPDFDocument(); + + AffineTransform at = new AffineTransform(); + at.translate(x, y); + useXObject(xObject, at, width, height); + } + + private void flushPDFDocument() { if (outputStream != null) { try { this.pdfDoc.output(outputStream); @@ -447,10 +455,6 @@ public class PDFGraphics2D extends AbstractGraphics2D { // ignore exception, will be thrown again later } } - - AffineTransform at = new AffineTransform(); - at.translate(x, y); - useXObject(xObject, at, width, height); } /** @@ -1044,13 +1048,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { this.pdfDoc.addObject(annots); } - if (outputStream != null) { - try { - this.pdfDoc.output(outputStream); - } catch (IOException ioe) { - // ignore exception, will be thrown again later - } - } + flushPDFDocument(); return true; } @@ -1147,26 +1145,14 @@ public class PDFGraphics2D extends AbstractGraphics2D { PDFImageXObject xobj = pdfDoc.addImage(resourceContext, fopimg); maskRef = xobj.referencePDF(); - if (outputStream != null) { - try { - this.pdfDoc.output(outputStream); - } catch (IOException ioe) { - // ignore exception, will be thrown again later - } - } + flushPDFDocument(); } BitmapImage fopimg; fopimg = new BitmapImage("TempImage:" + pctx.toString(), devW, devH, rgb, maskRef); fopimg.setTransparent(new PDFColor(255, 255, 255)); imageInfo = pdfDoc.addImage(resourceContext, fopimg); - if (outputStream != null) { - try { - this.pdfDoc.output(outputStream); - } catch (IOException ioe) { - // ignore exception, will be thrown again later - } - } + flushPDFDocument(); } currentStream.write("q\n"); @@ -1275,13 +1261,7 @@ public class PDFGraphics2D extends AbstractGraphics2D { ImageRendered imgRend = new ImageRendered(info, img, null); ImageRenderedAdapter adapter = new ImageRenderedAdapter(imgRend, key); PDFXObject xObject = pdfDoc.addImage(resourceContext, adapter); - if (outputStream != null) { - try { - this.pdfDoc.output(outputStream); - } catch (IOException ioe) { - // ignore exception, will be thrown again later - } - } + flushPDFDocument(); return xObject; } |