1 50 51 package com.lowagie.text.pdf; 52 53 58 59 public class PdfDestination extends PdfArray { 60 61 63 64 public static final int XYZ = 0; 65 66 67 public static final int FIT = 1; 68 69 70 public static final int FITH = 2; 71 72 73 public static final int FITV = 3; 74 75 76 public static final int FITR = 4; 77 78 79 public static final int FITB = 5; 80 81 82 public static final int FITBH = 6; 83 84 85 public static final int FITBV = 7; 86 87 89 90 private boolean status = false; 91 92 94 103 104 public PdfDestination(int type) { 105 super(); 106 if (type == FITB) { 107 add(PdfName.FITB); 108 } 109 else { 110 add(PdfName.FIT); 111 } 112 } 113 114 128 129 public PdfDestination(int type, float parameter) { 130 super(new PdfNumber(parameter)); 131 switch(type) { 132 default: 133 addFirst(PdfName.FITH); 134 break; 135 case FITV: 136 addFirst(PdfName.FITV); 137 break; 138 case FITBH: 139 addFirst(PdfName.FITBH); 140 break; 141 case FITBV: 142 addFirst(PdfName.FITBV); 143 } 144 } 145 146 157 158 public PdfDestination(int type, float left, float top, float zoom) { 159 super(PdfName.XYZ); 160 if (left < 0) 161 add(PdfNull.PDFNULL); 162 else 163 add(new PdfNumber(left)); 164 if (top < 0) 165 add(PdfNull.PDFNULL); 166 else 167 add(new PdfNumber(top)); 168 add(new PdfNumber(zoom)); 169 } 170 171 186 187 public PdfDestination(int type, float left, float bottom, float right, float top) { 188 super(PdfName.FITR); 189 add(new PdfNumber(left)); 190 add(new PdfNumber(bottom)); 191 add(new PdfNumber(right)); 192 add(new PdfNumber(top)); 193 } 194 195 197 202 203 public boolean hasPage() { 204 return status; 205 } 206 207 212 213 public boolean addPage(PdfIndirectReference page) { 214 if (!status) { 215 addFirst(page); 216 status = true; 217 return true; 218 } 219 return false; 220 } 221 } | Popular Tags |