1 51 package org.apache.fop.pdf; 52 53 import java.io.UnsupportedEncodingException ; 55 56 59 public class PDFGoToRemote extends PDFAction { 60 61 64 protected PDFFileSpec pdfFileSpec; 65 protected int pageReference = 0; 66 protected String destination = null; 67 68 74 public PDFGoToRemote(int number, PDFFileSpec pdfFileSpec) { 75 76 77 super(number); 78 79 this.pdfFileSpec = pdfFileSpec; 80 } 81 82 89 public PDFGoToRemote(int number, PDFFileSpec pdfFileSpec, int page) { 90 91 92 super(number); 93 94 this.pdfFileSpec = pdfFileSpec; 95 this.pageReference = page; 96 } 97 98 105 public PDFGoToRemote(int number, PDFFileSpec pdfFileSpec, String dest) { 106 107 108 super(number); 109 110 this.pdfFileSpec = pdfFileSpec; 111 this.destination = dest; 112 } 113 114 119 public String getAction() { 120 return this.referencePDF(); 121 } 122 123 128 public byte[] toPDF() { 129 String p = new String (this.number + " " + this.generation + " obj\n" 130 + "<<\n/S /GoToR\n" + "/F " 131 + pdfFileSpec.referencePDF() + "\n"); 132 133 if (destination != null) { 134 p += "/D (" + this.destination + ")"; 135 } else { 136 p += "/D [ " + this.pageReference + " /XYZ null null null ]"; 137 } 138 139 p += " \n>>\nendobj\n"; 140 141 try { 142 return p.getBytes(PDFDocument.ENCODING); 143 } catch (UnsupportedEncodingException ue) { 144 return p.getBytes(); 145 } 146 } 147 148 149 159 } 160 | Popular Tags |