1 51 package org.apache.fop.pdf; 52 53 import java.io.UnsupportedEncodingException ; 55 56 60 public class PDFGoTo extends PDFAction { 61 62 65 protected String pageReference; 66 protected String destination = null; 67 protected float xPosition = 0, yPosition = 0; 68 69 75 public PDFGoTo(int number, String pageReference) { 76 77 78 super(number); 79 80 this.pageReference = pageReference; 81 } 82 83 84 90 public void setPageReference(String pageReference) { 91 this.pageReference = pageReference; 92 } 93 94 public String getPageReference() { 95 return pageReference; 96 } 97 98 103 public void setYPosition(int yPosition) { 104 this.yPosition = (yPosition / 1000f); 105 } 106 107 public void setDestination(String dest) { 108 destination = dest; 109 } 110 111 116 public void setXPosition(int xPosition) { 117 this.xPosition = (xPosition / 1000f); 118 } 119 120 public String getAction() { 121 return referencePDF(); 122 } 123 124 125 130 public byte[] toPDF() { 131 if(destination == null) { 132 destination = "/D [" 133 + this.pageReference + " /XYZ " + xPosition 134 + " " + yPosition + " null]\n"; 135 } else { 136 destination = "/D [" 137 + this.pageReference + " " + destination + "]\n"; 138 } 139 String p = new String (this.number + " " + this.generation 140 + " obj\n<<\n/S /GoTo\n" + destination 141 + ">>\nendobj\n"); 142 143 try { 144 return p.getBytes(PDFDocument.ENCODING); 145 } catch (UnsupportedEncodingException ue) { 146 return p.getBytes(); 147 } 148 } 149 150 159 } 160 | Popular Tags |