1 |
package org.freehep.graphicsio.pdf.test; |
2 |
|
3 |
import org.freehep.graphics2d.*; |
4 |
|
5 |
import java.awt.*; |
6 |
import java.io.*; |
7 |
|
8 |
import org.freehep.graphicsio.pdf.PDFGraphics2D; |
9 |
|
10 |
public class TestPDFMultipage { |
11 |
|
12 |
public static void main(String[] argv) throws Exception { |
13 |
PDFGraphics2D graphics = new PDFGraphics2D(new FileOutputStream("multi.pdf"), new Dimension(400, 600)); |
14 |
graphics.setMultiPage(true); |
15 |
|
16 |
Font font = new Font("Serif", Font.PLAIN, 12); |
17 |
|
18 |
graphics.startExport(); |
19 |
graphics.setHeader(font, |
20 |
new TagString("TEST DOCUMENT"), |
21 |
null, |
22 |
new TagString("<i>Multipage</i>"), |
23 |
1); |
24 |
graphics.setFooter(font, |
25 |
null, |
26 |
new TagString("- %P% -"), |
27 |
null, |
28 |
-1); |
29 |
|
30 |
graphics.openPage(new Dimension(200, 400), "Page 1"); |
31 |
graphics.setColor(Color.black); |
32 |
graphics.setFont(font); |
33 |
graphics.drawRect(50, 100, 150, 20); |
34 |
graphics.drawString("Page 1", 60., 115); |
35 |
graphics.closePage(); |
36 |
|
37 |
graphics.openPage(new Dimension(200, 400), "Page 2"); |
38 |
graphics.setColor(Color.black); |
39 |
graphics.setFont(new Font("SansSerif", Font.PLAIN, 12)); |
40 |
graphics.drawRect(50, 100, 150, 20); |
41 |
graphics.drawString("Page 2", 60., 115); |
42 |
graphics.drawString(new TagString("This is <tt>Page 2</tt> of 2"), 40.,150); |
43 |
graphics.closePage(); |
44 |
|
45 |
graphics.endExport(); |
46 |
|
47 |
System.exit(0); |
48 |
} |
49 |
} |