Browse Source

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
tags/Alt-Design-integration-base
Christian Geisert 22 years ago
parent
commit
53a25ebdee

+ 10
- 0
docs/examples/fo/link.fo View File

@@ -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"

+ 17
- 0
src/org/apache/fop/pdf/PDFDocument.java View File

@@ -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);

+ 44
- 3
src/org/apache/fop/pdf/PDFGoToRemote.java View File

@@ -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.
@@ -31,6 +33,38 @@ public class PDFGoToRemote extends PDFAction {
this.pdfFileSpec = pdfFileSpec;
}

/**
* 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
*
@@ -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();
}


+ 6
- 0
status.xml View File

@@ -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>

Loading…
Cancel
Save