1 50 51 package com.lowagie.text; 52 53 import java.lang.reflect.Field ; 54 55 60 61 public class PageSize { 62 63 65 66 public static final Rectangle LETTER = new Rectangle(612,792); 67 68 69 public static final Rectangle NOTE = new Rectangle(540,720); 70 71 72 public static final Rectangle LEGAL = new Rectangle(612,1008); 73 74 75 public static final Rectangle TABLOID = new Rectangle(792,1224); 76 77 78 public static final Rectangle EXECUTIVE = new Rectangle(522,756); 79 80 81 public static final Rectangle POSTCARD = new Rectangle(283,416); 82 83 84 public static final Rectangle A0 = new Rectangle(2384,3370); 85 86 87 public static final Rectangle A1 = new Rectangle(1684,2384); 88 89 90 public static final Rectangle A2 = new Rectangle(1191,1684); 91 92 93 public static final Rectangle A3 = new Rectangle(842,1191); 94 95 96 public static final Rectangle A4 = new Rectangle(595,842); 97 98 99 public static final Rectangle A5 = new Rectangle(420,595); 100 101 102 public static final Rectangle A6 = new Rectangle(297,420); 103 104 105 public static final Rectangle A7 = new Rectangle(210,297); 106 107 108 public static final Rectangle A8 = new Rectangle(148,210); 109 110 111 public static final Rectangle A9 = new Rectangle(105,148); 112 113 114 public static final Rectangle A10 = new Rectangle(73,105); 115 116 117 public static final Rectangle B0 = new Rectangle(2834,4008); 118 119 120 public static final Rectangle B1 = new Rectangle(2004,2834); 121 122 123 public static final Rectangle B2 = new Rectangle(1417,2004); 124 125 126 public static final Rectangle B3 = new Rectangle(1000,1417); 127 128 129 public static final Rectangle B4 = new Rectangle(708,1000); 130 131 132 public static final Rectangle B5 = new Rectangle(498,708); 133 134 135 public static final Rectangle B6 = new Rectangle(354,498); 136 137 138 public static final Rectangle B7 = new Rectangle(249,354); 139 140 141 public static final Rectangle B8 = new Rectangle(175,249); 142 143 144 public static final Rectangle B9 = new Rectangle(124,175); 145 146 147 public static final Rectangle B10 = new Rectangle(87,124); 148 149 150 public static final Rectangle ARCH_E = new Rectangle(2592,3456); 151 152 153 public static final Rectangle ARCH_D = new Rectangle(1728,2592); 154 155 156 public static final Rectangle ARCH_C = new Rectangle(1296,1728); 157 158 159 public static final Rectangle ARCH_B = new Rectangle(864,1296); 160 161 162 public static final Rectangle ARCH_A = new Rectangle(648,864); 163 164 165 public static final Rectangle FLSA = new Rectangle(612,936); 166 167 168 public static final Rectangle FLSE = new Rectangle(648,936); 169 170 171 public static final Rectangle HALFLETTER = new Rectangle(396,612); 172 173 174 public static final Rectangle _11X17 = new Rectangle(792,1224); 175 176 177 public static final Rectangle ID_1 = new Rectangle(242.65f,153); 178 179 180 public static final Rectangle ID_2 = new Rectangle(297,210); 181 182 183 public static final Rectangle ID_3 = new Rectangle(354,249); 184 185 186 public static final Rectangle LEDGER = new Rectangle(1224,792); 187 188 189 public static final Rectangle CROWN_QUARTO = new Rectangle(535,697); 190 191 192 public static final Rectangle LARGE_CROWN_QUARTO = new Rectangle(569,731); 193 194 195 public static final Rectangle DEMY_QUARTO = new Rectangle(620,782); 196 197 198 public static final Rectangle ROYAL_QUARTO = new Rectangle(671,884); 199 200 201 public static final Rectangle CROWN_OCTAVO = new Rectangle(348,527); 202 203 204 public static final Rectangle LARGE_CROWN_OCTAVO = new Rectangle(365,561); 205 206 207 public static final Rectangle DEMY_OCTAVO = new Rectangle(391,612); 208 209 210 public static final Rectangle ROYAL_OCTAVO = new Rectangle(442,663); 211 212 213 public static final Rectangle SMALL_PAPERBACK = new Rectangle(314,504); 214 215 216 public static final Rectangle PENGUIN_SMALL_PAPERBACK = new Rectangle(314,513); 217 218 219 public static final Rectangle PENGUIN_LARGE_PAPERBACK = new Rectangle(365,561); 220 221 226 public static Rectangle getRectangle(String name) { 227 name = name.trim().toUpperCase(); 228 int pos = name.indexOf(' '); 229 if (pos == -1) { 230 try { 231 Field field = PageSize.class.getDeclaredField(name.toUpperCase()); 232 return (Rectangle) field.get(null); 233 } catch (Exception e) { 234 throw new RuntimeException ("Can't find page size " + name); 235 } 236 } 237 else { 238 try { 239 String width = name.substring(0, pos); 240 String height = name.substring(pos + 1); 241 return new Rectangle(Float.parseFloat(width), Float.parseFloat(height)); 242 } catch(Exception e) { 243 throw new RuntimeException (name + " is not a valid page size format; " + e.getMessage()); 244 } 245 } 246 } 247 } | Popular Tags |