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/pdf/PDFPages.java | |
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/pdf/PDFPages.java')
-rw-r--r-- | src/java/org/apache/fop/pdf/PDFPages.java | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/java/org/apache/fop/pdf/PDFPages.java b/src/java/org/apache/fop/pdf/PDFPages.java index aae5c6c90..6ce4830e1 100644 --- a/src/java/org/apache/fop/pdf/PDFPages.java +++ b/src/java/org/apache/fop/pdf/PDFPages.java @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -72,7 +72,19 @@ public class PDFPages extends PDFObject { * @param page the child page */ public void notifyKidRegistered(PDFPage page) { - this.kids.add(page.referencePDF()); + int idx = page.getPageIndex(); + if (idx >= 0) { + while (idx > this.kids.size() - 1) { + this.kids.add(null); + } + if (this.kids.get(idx) != null) { + throw new IllegalStateException("A page already exists at index " + + idx + " (zero-based)."); + } + this.kids.set(idx, page.referencePDF()); + } else { + this.kids.add(page.referencePDF()); + } } /** @@ -102,7 +114,11 @@ public class PDFPages extends PDFObject { append(this.getCount()). append("\n/Kids ["); for (int i = 0; i < kids.size(); i++) { - sb.append(kids.get(i)).append(" "); + Object kid = kids.get(i); + if (kid == null) { + throw new IllegalStateException("Gap in the kids list!"); + } + sb.append(kid).append(" "); } sb.append("] >>\nendobj\n"); return sb.toString(); |