diff options
-rw-r--r-- | docs/examples/fo/link.fo | 10 | ||||
-rw-r--r-- | src/org/apache/fop/pdf/PDFDocument.java | 17 | ||||
-rw-r--r-- | src/org/apache/fop/pdf/PDFGoToRemote.java | 47 | ||||
-rw-r--r-- | status.xml | 6 |
4 files changed, 77 insertions, 3 deletions
diff --git a/docs/examples/fo/link.fo b/docs/examples/fo/link.fo index 28ab1b31e..e44efcc27 100644 --- a/docs/examples/fo/link.fo +++ b/docs/examples/fo/link.fo @@ -114,6 +114,16 @@ go to <fo:basic-link external-destination="normal.pdf">normal.pdf</fo:basic-link> </fo:block> + <!-- Normal text --> + <fo:block text-align="start" + space-before.optimum="6pt" + line-height="24pt" + font-family="serif" + padding-top="3pt" + > + 9. Linking to a specific page of an external: + <fo:basic-link external-destination="extensive.pdf#page=1">extensive.pdf, Page 2</fo:basic-link>. + </fo:block> <!-- Normal text --> <!-- <fo:block text-align="start" diff --git a/src/org/apache/fop/pdf/PDFDocument.java b/src/org/apache/fop/pdf/PDFDocument.java index e483b6791..8dd9c0c86 100644 --- a/src/org/apache/fop/pdf/PDFDocument.java +++ b/src/org/apache/fop/pdf/PDFDocument.java @@ -1233,6 +1233,7 @@ public class PDFDocument { PDFLink linkObject; PDFAction action; + int index; PDFLink link = new PDFLink(++this.objectcount, rect); this.objects.add(link); @@ -1246,6 +1247,22 @@ public class PDFDocument { action = new PDFGoToRemote(++this.objectcount, fileSpec); this.objects.add(action); link.setAction(action); + } else if ((index = destination.indexOf(".pdf#page=")) > 0) { + String file = destination.substring(0, index + 4); + int page = Integer.parseInt(destination.substring(index + 10)); + PDFFileSpec fileSpec = new PDFFileSpec(++this.objectcount, file); + this.objects.add(fileSpec); + action = new PDFGoToRemote(++this.objectcount, fileSpec, page); + this.objects.add(action); + link.setAction(action); + } else if ((index = destination.indexOf(".pdf#dest=")) > 0) { + String file = destination.substring(0, index + 4); + String dest = destination.substring(index + 10); + PDFFileSpec fileSpec = new PDFFileSpec(++this.objectcount, file); + this.objects.add(fileSpec); + action = new PDFGoToRemote(++this.objectcount, fileSpec, dest); + this.objects.add(action); + link.setAction(action); } else { // URI PDFUri uri = new PDFUri(destination); link.setAction(uri); diff --git a/src/org/apache/fop/pdf/PDFGoToRemote.java b/src/org/apache/fop/pdf/PDFGoToRemote.java index aa8ef5afa..ad102034c 100644 --- a/src/org/apache/fop/pdf/PDFGoToRemote.java +++ b/src/org/apache/fop/pdf/PDFGoToRemote.java @@ -16,6 +16,8 @@ public class PDFGoToRemote extends PDFAction { * the file specification */ protected PDFFileSpec pdfFileSpec; + protected int pageReference = 0; + protected String destination = null; /** * create an GoToR object. @@ -32,6 +34,38 @@ public class PDFGoToRemote extends PDFAction { } /** + * create an GoToR object. + * + * @param number the object's number + * @param fileSpec the fileSpec associated with the action + * @param page a page reference within the remote document + */ + public PDFGoToRemote(int number, PDFFileSpec pdfFileSpec, int page) { + + /* generic creation of object */ + super(number); + + this.pdfFileSpec = pdfFileSpec; + this.pageReference = page; + } + + /** + * create an GoToR object. + * + * @param number the object's number + * @param fileSpec the fileSpec associated with the action + * @param dest a named destination within the remote document + */ + public PDFGoToRemote(int number, PDFFileSpec pdfFileSpec, String dest) { + + /* generic creation of object */ + super(number); + + this.pdfFileSpec = pdfFileSpec; + this.destination = dest; + } + + /** * return the action string which will reference this object * * @return the action String @@ -48,9 +82,16 @@ public class PDFGoToRemote extends PDFAction { public byte[] toPDF() { String p = new String(this.number + " " + this.generation + " obj\n" + "<<\n/S /GoToR\n" + "/F " - + pdfFileSpec.referencePDF() + "\n" - + "/D [ 0 /XYZ null null null ]" - + " \n>>\nendobj\n"); + + pdfFileSpec.referencePDF() + "\n"); + + if (destination != null) { + p += "/D (" + this.destination + ")"; + } else { + p += "/D [ " + this.pageReference + " /XYZ null null null ]"; + } + + p += " \n>>\nendobj\n"; + return p.getBytes(); } diff --git a/status.xml b/status.xml index ee6aef97b..b364b4585 100644 --- a/status.xml +++ b/status.xml @@ -123,6 +123,12 @@ inactive?? <changes> <release version="?" date="2002"> + <action dev="CG" type="add" context="code" + due-to="Bernd Brandstetter" due-to-email="bbrand@freenet.de"> + Linking to a specific page and a named destinations of an + external PDF file. + (see www.adobe.com/products/acrobat/pdfs/c01acrotip.pdf) + </action> <action context="code" dev="KLL" type="update"> Started table layout managers. </action> |