diff options
author | Jeremias Maerki <jeremias@apache.org> | 2005-10-18 16:06:31 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2005-10-18 16:06:31 +0000 |
commit | 20be3fe07bda82ab51d180744cba05ed707d8276 (patch) | |
tree | e7b9a68ba93e08aa7b77fd8b38a8cafbf7a69fda /src/java/org/apache/fop/render | |
parent | 4273340fedb25e6f3ea47f5750d3c5592fd4630f (diff) | |
download | xmlgraphics-fop-20be3fe07bda82ab51d180744cba05ed707d8276.tar.gz xmlgraphics-fop-20be3fe07bda82ab51d180744cba05ed707d8276.zip |
Fix for internal forward references in PDF output (basic-link with internal-destination):
Implemented by making out-of-order processing possible. The problem will still surface if supportsOutOfOrder() returns false.
PDF library now supports the addition of pages in non-consecutive order. This is a backwards-compatible change. The old behaviour and the old method signatures are still in place.
PageViewport now carries a page index which doesn't represent the page number but the overall index of the page within the current rendering run.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@326133 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render')
-rw-r--r-- | src/java/org/apache/fop/render/pdf/PDFRenderer.java | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index ba8b6796e..70beb20fb 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -283,7 +283,8 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { * @see org.apache.fop.render.Renderer#supportsOutOfOrder() */ public boolean supportsOutOfOrder() { - return false; + //return false; + return true; } /** @@ -402,6 +403,14 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { * @param page the page to prepare */ public void preparePage(PageViewport page) { + setupPage(page); + if (pages == null) { + pages = new java.util.HashMap(); + } + pages.put(page, currentPage); + } + + private void setupPage(PageViewport page) { this.pdfResources = this.pdfDoc.getResources(); Rectangle2D bounds = page.getViewArea(); @@ -409,15 +418,12 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { double h = bounds.getHeight(); currentPage = this.pdfDoc.getFactory().makePage( this.pdfResources, - (int) Math.round(w / 1000), (int) Math.round(h / 1000)); - if (pages == null) { - pages = new java.util.HashMap(); - } - pages.put(page, currentPage); + (int) Math.round(w / 1000), (int) Math.round(h / 1000), + page.getPageIndex()); pageReferences.put(page.getKey(), currentPage.referencePDF()); pvReferences.put(page.getKey(), page); } - + /** * This method creates a pdf stream for the current page * uses it as the contents of a new page. The page is written @@ -428,22 +434,15 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { throws IOException, FOPException { if (pages != null && (currentPage = (PDFPage) pages.get(page)) != null) { + //Retrieve previously prepared page (out-of-line rendering) pages.remove(page); - Rectangle2D bounds = page.getViewArea(); - double h = bounds.getHeight(); - pageHeight = (int) h; } else { - this.pdfResources = this.pdfDoc.getResources(); - Rectangle2D bounds = page.getViewArea(); - double w = bounds.getWidth(); - double h = bounds.getHeight(); - pageHeight = (int) h; - currentPage = this.pdfDoc.getFactory().makePage( - this.pdfResources, - (int) Math.round(w / 1000), (int) Math.round(h / 1000)); - pageReferences.put(page.getKey(), currentPage.referencePDF()); - pvReferences.put(page.getKey(), page); + setupPage(page); } + Rectangle2D bounds = page.getViewArea(); + double h = bounds.getHeight(); + pageHeight = (int) h; + currentStream = this.pdfDoc.getFactory() .makeStream(PDFFilterList.CONTENT_FILTER, false); |