aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop
diff options
context:
space:
mode:
authorChristian Geisert <chrisg@apache.org>2002-10-16 17:01:56 +0000
committerChristian Geisert <chrisg@apache.org>2002-10-16 17:01:56 +0000
commit53a25ebdeeeee1b25ba459100590584d868f2b7a (patch)
tree7dc0aac73f094fe34adbb30ad85349f6fdd92d7f /src/org/apache/fop
parent0cadd453fe88b6e94f5a535e6838fa8aca7aeac6 (diff)
downloadxmlgraphics-fop-53a25ebdeeeee1b25ba459100590584d868f2b7a.tar.gz
xmlgraphics-fop-53a25ebdeeeee1b25ba459100590584d868f2b7a.zip
Addes Linking to a specific page and a named destinations of an
external PDF file (see www.adobe.com/products/acrobat/pdfs/c01acrotip.pdf) Submitted by: Bernd Brandstetter <bbrand@freenet.de> git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195332 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop')
-rw-r--r--src/org/apache/fop/pdf/PDFDocument.java17
-rw-r--r--src/org/apache/fop/pdf/PDFGoToRemote.java47
2 files changed, 61 insertions, 3 deletions
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();
}