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"
PDFLink linkObject;
PDFAction action;
+ int index;
PDFLink link = new PDFLink(++this.objectcount, rect);
this.objects.add(link);
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);
* the file specification
*/
protected PDFFileSpec pdfFileSpec;
+ protected int pageReference = 0;
+ protected String destination = null;
/**
* create an GoToR object.
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
*
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();
}
<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>