iText では出力する PDF の紙のサイズを com.lowagie.text.Rectangle クラスのオブジェクトで指定できる。
A4 とか B5 とか有名な紙の大きさについては com.lowagie.text.PageSize クラスが定数の Rectangle オブジェクトを持っている。
その Rectangle 定数の一覧を表にしてみた。
定数名 | 説明 | サイズ(ピクセル) | サイズ(ミリメートル) |
---|---|---|---|
_11X17 | This is the 11x17 format | 792.0,1224.0 | 279.4,431.8 |
A0 | This is the a0 format | 2384.0,3370.0 | 841.0222,1188.8611 |
A1 | This is the a1 format | 1684.0,2384.0 | 594.07776,841.0222 |
A10 | This is the a10 format | 73.0,105.0 | 25.752777,37.041668 |
A2 | This is the a2 format | 1191.0,1684.0 | 420.15833,594.07776 |
A3 | This is the a3 format | 842.0,1191.0 | 297.03888,420.15833 |
A4 | This is the a4 format | 595.0,842.0 | 209.90277,297.03888 |
A5 | This is the a5 format | 420.0,595.0 | 148.16667,209.90277 |
A6 | This is the a6 format | 297.0,420.0 | 104.774994,148.16667 |
A7 | This is the a7 format | 210.0,297.0 | 74.083336,104.774994 |
A8 | This is the a8 format | 148.0,210.0 | 52.21111,74.083336 |
A9 | This is the a9 format | 105.0,148.0 | 37.041668,52.21111 |
ARCH_A | This is the archA format | 648.0,864.0 | 228.59999,304.8 |
ARCH_B | This is the archB format | 864.0,1296.0 | 304.8,457.19998 |
ARCH_C | This is the archC format | 1296.0,1728.0 | 457.19998,609.6 |
ARCH_D | This is the archD format | 1728.0,2592.0 | 609.6,914.39996 |
ARCH_E | This is the archE format | 2592.0,3456.0 | 914.39996,1219.2 |
B0 | This is the b0 format | 2834.0,4008.0 | 999.7722,1413.9332 |
B1 | This is the b1 format | 2004.0,2834.0 | 706.9666,999.7722 |
B10 | This is the b10 format | 87.0,124.0 | 30.691668,43.744442 |
B2 | This is the b2 format | 1417.0,2004.0 | 499.8861,706.9666 |
B3 | This is the b3 format | 1000.0,1417.0 | 352.77777,499.8861 |
B4 | This is the b4 format | 708.0,1000.0 | 249.76666,352.77777 |
B5 | This is the b5 format | 498.0,708.0 | 175.68333,249.76666 |
B6 | This is the b6 format | 354.0,498.0 | 124.88333,175.68333 |
B7 | This is the b7 format | 249.0,354.0 | 87.84167,124.88333 |
B8 | This is the b8 format | 175.0,249.0 | 61.73611,87.84167 |
B9 | This is the b9 format | 124.0,175.0 | 43.744442,61.73611 |
CROWN_OCTAVO | This is the Crown Octavo format | 348.0,527.0 | 122.76667,185.91388 |
CROWN_QUARTO | This is the Crown Quarto format | 535.0,697.0 | 188.73611,245.8861 |
DEMY_OCTAVO | This is the Demy Octavo format | 391.0,612.0 | 137.9361,215.9 |
DEMY_QUARTO | This is the Demy Quarto format. | 620.0,782.0 | 218.72223,275.8722 |
EXECUTIVE | This is the executive format | 522.0,756.0 | 184.15,266.7 |
FLSA | This is the American Foolscap format | 612.0,936.0 | 215.9,330.2 |
FLSE | This is the European Foolscap format | 648.0,936.0 | 228.59999,330.2 |
HALFLETTER | This is the halfletter format | 396.0,612.0 | 139.7,215.9 |
ID_1 | This is the ISO 7810 ID-1 format (85.60 x 53.98 mm or 3.370 x 2.125 inch) | 242.65,153.0 | 85.601524,53.975 |
ID_2 | This is the ISO 7810 ID-2 format (A7 rotated) | 297.0,210.0 | 104.774994,74.083336 |
ID_3 | This is the ISO 7810 ID-3 format (B7 rotated) | 354.0,249.0 | 124.88333,87.84167 |
LARGE_CROWN_OCTAVO | This is the Large Crown Octavo format | 365.0,561.0 | 128.76389,197.90833 |
LARGE_CROWN_QUARTO | This is the Large Crown Quarto format | 569.0,731.0 | 200.73055,257.88055 |
LEDGER | This is the ledger format | 1224.0,792.0 | 431.8,279.4 |
LEGAL | This is the legal format | 612.0,1008.0 | 215.9,355.59998 |
LETTER | This is the letter format | 612.0,792.0 | 215.9,279.4 |
NOTE | This is the note format | 540.0,720.0 | 190.5,254.0 |
PENGUIN_LARGE_PAPERBACK | This is the Penguin large paparback format. | 365.0,561.0 | 128.76389,197.90833 |
PENGUIN_SMALL_PAPERBACK | This is the Pengiun small paperback format. | 314.0,513.0 | 110.772224,180.975 |
POSTCARD | This is the postcard format | 283.0,416.0 | 99.836105,146.75555 |
ROYAL_OCTAVO | This is the Royal Octavo format. | 442.0,663.0 | 155.92778,233.89166 |
ROYAL_QUARTO | This is the Royal Quarto format. | 671.0,884.0 | 236.7139,311.85556 |
SMALL_PAPERBACK | This is the small paperback format. | 314.0,504.0 | 110.772224,177.79999 |
TABLOID | This is the tabloid format | 792.0,1224.0 | 279.4,431.8 |
表を作るためのソースコード(PageSizeRectangles.java)
import java.lang.reflect.Field;
import com.lowagie.text.PageSize;
import com.lowagie.text.Rectangle;
public class PageSizeRectangles {
public static void main(String[] args) throws Exception{
String[] names = {
"_11X17", // PageSize._11X17
"A0",
"A1",
"A10",
"A2",
"A3",
"A4",
"A5",
"A6",
"A7",
"A8",
"A9",
"ARCH_A",
"ARCH_B",
"ARCH_C",
"ARCH_D",
"ARCH_E",
"B0",
"B1",
"B10",
"B2",
"B3",
"B4",
"B5",
"B6",
"B7",
"B8",
"B9",
"CROWN_OCTAVO",
"CROWN_QUARTO",
"DEMY_OCTAVO",
"DEMY_QUARTO",
"EXECUTIVE",
"FLSA",
"FLSE",
"HALFLETTER",
"ID_1",
"ID_2",
"ID_3",
"LARGE_CROWN_OCTAVO",
"LARGE_CROWN_QUARTO",
"LEDGER",
"LEGAL",
"LETTER",
"NOTE",
"PENGUIN_LARGE_PAPERBACK",
"PENGUIN_SMALL_PAPERBACK",
"POSTCARD",
"ROYAL_OCTAVO",
"ROYAL_QUARTO",
"SMALL_PAPERBACK",
"TABLOID",
};
String[] descs = {
"This is the 11x17 format",
"This is the a0 format",
"This is the a1 format",
"This is the a10 format",
"This is the a2 format",
"This is the a3 format",
"This is the a4 format",
"This is the a5 format",
"This is the a6 format",
"This is the a7 format",
"This is the a8 format",
"This is the a9 format",
"This is the archA format",
"This is the archB format",
"This is the archC format",
"This is the archD format",
"This is the archE format",
"This is the b0 format",
"This is the b1 format",
"This is the b10 format",
"This is the b2 format",
"This is the b3 format",
"This is the b4 format",
"This is the b5 format",
"This is the b6 format",
"This is the b7 format",
"This is the b8 format",
"This is the b9 format",
"This is the Crown Octavo format",
"This is the Crown Quarto format",
"This is the Demy Octavo format",
"This is the Demy Quarto format.",
"This is the executive format",
"This is the American Foolscap format",
"This is the European Foolscap format",
"This is the halfletter format",
"This is the ISO 7810 ID-1 format (85.60 x 53.98 mm or 3.370 x 2.125 inch)",
"This is the ISO 7810 ID-2 format (A7 rotated)",
"This is the ISO 7810 ID-3 format (B7 rotated)",
"This is the Large Crown Octavo format",
"This is the Large Crown Quarto format",
"This is the ledger format",
"This is the legal format",
"This is the letter format",
"This is the note format",
"This is the Penguin large paparback format.",
"This is the Pengiun small paperback format.",
"This is the postcard format",
"This is the Royal Octavo format.",
"This is the Royal Quarto format.",
"This is the small paperback format.",
"This is the tabloid format",
};
System.out.println("<table border=\"1\">");
System.out.println(
"<tr><th>" + "定数名" +
"</th><th>" + "説明" +
"</th><th>" + "サイズ(ピクセル)" +
"</th><th>" + "サイズ(ミリメートル)" +
"</th></tr>");
for(int i=0; i<names.length; i++){
out(names[i], descs[i]);
}
System.out.println("</table>");
}
private static void out(String name, String desc) throws Exception{
// わざわざリフレクションでフィールドを求める(^_^;
Field field = PageSize.class.getDeclaredField(name);
Rectangle size = (Rectangle)field.get(null);
System.out.println(
"<tr><td>" + name +
"</td><td>" + desc +
"</td><td>" + size.getWidth() + "," + size.getHeight() +
"</td><td>" + pixel2mm(size.getWidth()) + "," + pixel2mm(size.getHeight()) +
"</td></tr>");
}
public static float pixel2mm(float pixel) {
final float dpi = 72.0f;
return pixel * 25.4f / dpi;
}
}
tags: zlashdot Java Java PDF iText
Posted by NI-Lab. (@nilab)