001: /*
002: * $Id: PageSize.java 2748 2007-05-12 15:11:48Z blowagie $
003: * $Name$
004: *
005: * Copyright 1999, 2000, 2001, 2002 by Bruno Lowagie.
006: *
007: * The contents of this file are subject to the Mozilla Public License Version 1.1
008: * (the "License"); you may not use this file except in compliance with the License.
009: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
010: *
011: * Software distributed under the License is distributed on an "AS IS" basis,
012: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
013: * for the specific language governing rights and limitations under the License.
014: *
015: * The Original Code is 'iText, a free JAVA-PDF library'.
016: *
017: * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
018: * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
019: * All Rights Reserved.
020: * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
021: * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
022: *
023: * Contributor(s): all the names of the contributors are added in the source code
024: * where applicable.
025: *
026: * Alternatively, the contents of this file may be used under the terms of the
027: * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
028: * provisions of LGPL are applicable instead of those above. If you wish to
029: * allow use of your version of this file only under the terms of the LGPL
030: * License and not to allow others to use your version of this file under
031: * the MPL, indicate your decision by deleting the provisions above and
032: * replace them with the notice and other provisions required by the LGPL.
033: * If you do not delete the provisions above, a recipient may use your version
034: * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
035: *
036: * This library is free software; you can redistribute it and/or modify it
037: * under the terms of the MPL as stated above or under the terms of the GNU
038: * Library General Public License as published by the Free Software Foundation;
039: * either version 2 of the License, or any later version.
040: *
041: * This library is distributed in the hope that it will be useful, but WITHOUT
042: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
043: * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
044: * details.
045: *
046: * If you didn't download this code from the following link, you should check if
047: * you aren't using an obsolete version:
048: * http://www.lowagie.com/iText/
049: */
050:
051: package com.lowagie.text;
052:
053: import java.lang.reflect.Field;
054:
055: /**
056: * The <CODE>PageSize</CODE>-object contains a number of rectangles representing the most common papersizes.
057: *
058: * @see Rectangle
059: */
060:
061: public class PageSize {
062:
063: // membervariables
064:
065: /** This is the letter format */
066: public static final Rectangle LETTER = new Rectangle(612, 792);
067:
068: /** This is the note format */
069: public static final Rectangle NOTE = new Rectangle(540, 720);
070:
071: /** This is the legal format */
072: public static final Rectangle LEGAL = new Rectangle(612, 1008);
073:
074: /** This is the tabloid format */
075: public static final Rectangle TABLOID = new Rectangle(792, 1224);
076:
077: /** This is the executive format */
078: public static final Rectangle EXECUTIVE = new Rectangle(522, 756);
079:
080: /** This is the postcard format */
081: public static final Rectangle POSTCARD = new Rectangle(283, 416);
082:
083: /** This is the a0 format */
084: public static final Rectangle A0 = new Rectangle(2384, 3370);
085:
086: /** This is the a1 format */
087: public static final Rectangle A1 = new Rectangle(1684, 2384);
088:
089: /** This is the a2 format */
090: public static final Rectangle A2 = new Rectangle(1191, 1684);
091:
092: /** This is the a3 format */
093: public static final Rectangle A3 = new Rectangle(842, 1191);
094:
095: /** This is the a4 format */
096: public static final Rectangle A4 = new Rectangle(595, 842);
097:
098: /** This is the a5 format */
099: public static final Rectangle A5 = new Rectangle(420, 595);
100:
101: /** This is the a6 format */
102: public static final Rectangle A6 = new Rectangle(297, 420);
103:
104: /** This is the a7 format */
105: public static final Rectangle A7 = new Rectangle(210, 297);
106:
107: /** This is the a8 format */
108: public static final Rectangle A8 = new Rectangle(148, 210);
109:
110: /** This is the a9 format */
111: public static final Rectangle A9 = new Rectangle(105, 148);
112:
113: /** This is the a10 format */
114: public static final Rectangle A10 = new Rectangle(73, 105);
115:
116: /** This is the b0 format */
117: public static final Rectangle B0 = new Rectangle(2834, 4008);
118:
119: /** This is the b1 format */
120: public static final Rectangle B1 = new Rectangle(2004, 2834);
121:
122: /** This is the b2 format */
123: public static final Rectangle B2 = new Rectangle(1417, 2004);
124:
125: /** This is the b3 format */
126: public static final Rectangle B3 = new Rectangle(1000, 1417);
127:
128: /** This is the b4 format */
129: public static final Rectangle B4 = new Rectangle(708, 1000);
130:
131: /** This is the b5 format */
132: public static final Rectangle B5 = new Rectangle(498, 708);
133:
134: /** This is the b6 format */
135: public static final Rectangle B6 = new Rectangle(354, 498);
136:
137: /** This is the b7 format */
138: public static final Rectangle B7 = new Rectangle(249, 354);
139:
140: /** This is the b8 format */
141: public static final Rectangle B8 = new Rectangle(175, 249);
142:
143: /** This is the b9 format */
144: public static final Rectangle B9 = new Rectangle(124, 175);
145:
146: /** This is the b10 format */
147: public static final Rectangle B10 = new Rectangle(87, 124);
148:
149: /** This is the archE format */
150: public static final Rectangle ARCH_E = new Rectangle(2592, 3456);
151:
152: /** This is the archD format */
153: public static final Rectangle ARCH_D = new Rectangle(1728, 2592);
154:
155: /** This is the archC format */
156: public static final Rectangle ARCH_C = new Rectangle(1296, 1728);
157:
158: /** This is the archB format */
159: public static final Rectangle ARCH_B = new Rectangle(864, 1296);
160:
161: /** This is the archA format */
162: public static final Rectangle ARCH_A = new Rectangle(648, 864);
163:
164: /** This is the American Foolscap format */
165: public static final Rectangle FLSA = new Rectangle(612, 936);
166:
167: /** This is the European Foolscap format */
168: public static final Rectangle FLSE = new Rectangle(648, 936);
169:
170: /** This is the halfletter format */
171: public static final Rectangle HALFLETTER = new Rectangle(396, 612);
172:
173: /** This is the 11x17 format */
174: public static final Rectangle _11X17 = new Rectangle(792, 1224);
175:
176: /** This is the ISO 7810 ID-1 format (85.60 x 53.98 mm or 3.370 x 2.125 inch) */
177: public static final Rectangle ID_1 = new Rectangle(242.65f, 153);
178:
179: /** This is the ISO 7810 ID-2 format (A7 rotated) */
180: public static final Rectangle ID_2 = new Rectangle(297, 210);
181:
182: /** This is the ISO 7810 ID-3 format (B7 rotated) */
183: public static final Rectangle ID_3 = new Rectangle(354, 249);
184:
185: /** This is the ledger format */
186: public static final Rectangle LEDGER = new Rectangle(1224, 792);
187:
188: /** This is the Crown Quarto format */
189: public static final Rectangle CROWN_QUARTO = new Rectangle(535, 697);
190:
191: /** This is the Large Crown Quarto format */
192: public static final Rectangle LARGE_CROWN_QUARTO = new Rectangle(
193: 569, 731);
194:
195: /** This is the Demy Quarto format. */
196: public static final Rectangle DEMY_QUARTO = new Rectangle(620, 782);
197:
198: /** This is the Royal Quarto format. */
199: public static final Rectangle ROYAL_QUARTO = new Rectangle(671, 884);
200:
201: /** This is the Crown Octavo format */
202: public static final Rectangle CROWN_OCTAVO = new Rectangle(348, 527);
203:
204: /** This is the Large Crown Octavo format */
205: public static final Rectangle LARGE_CROWN_OCTAVO = new Rectangle(
206: 365, 561);
207:
208: /** This is the Demy Octavo format */
209: public static final Rectangle DEMY_OCTAVO = new Rectangle(391, 612);
210:
211: /** This is the Royal Octavo format. */
212: public static final Rectangle ROYAL_OCTAVO = new Rectangle(442, 663);
213:
214: /** This is the small paperback format. */
215: public static final Rectangle SMALL_PAPERBACK = new Rectangle(314,
216: 504);
217:
218: /** This is the Pengiun small paperback format. */
219: public static final Rectangle PENGUIN_SMALL_PAPERBACK = new Rectangle(
220: 314, 513);
221:
222: /** This is the Penguin large paparback format. */
223: public static final Rectangle PENGUIN_LARGE_PAPERBACK = new Rectangle(
224: 365, 561);
225:
226: /**
227: * This method returns a Rectangle based on a String.
228: * Possible values are the the names of a constant in this class
229: * (for instance "A4", "LETTER",...) or a value like "595 842"
230: */
231: public static Rectangle getRectangle(String name) {
232: name = name.trim().toUpperCase();
233: int pos = name.indexOf(' ');
234: if (pos == -1) {
235: try {
236: Field field = PageSize.class.getDeclaredField(name
237: .toUpperCase());
238: return (Rectangle) field.get(null);
239: } catch (Exception e) {
240: throw new RuntimeException("Can't find page size "
241: + name);
242: }
243: } else {
244: try {
245: String width = name.substring(0, pos);
246: String height = name.substring(pos + 1);
247: return new Rectangle(Float.parseFloat(width), Float
248: .parseFloat(height));
249: } catch (Exception e) {
250: throw new RuntimeException(name
251: + " is not a valid page size format; "
252: + e.getMessage());
253: }
254: }
255: }
256: }
|