File: TestPDFMultipage.java

package info (click to toggle)
freehep-graphicsio-pdf 2.1.1+dfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 360 kB
  • sloc: java: 3,555; xml: 75; sh: 10; makefile: 3
file content (49 lines) | stat: -rw-r--r-- 1,400 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package org.freehep.graphicsio.pdf.test;

import org.freehep.graphics2d.*;

import java.awt.*;
import java.io.*;

import org.freehep.graphicsio.pdf.PDFGraphics2D;

public class TestPDFMultipage {

    public static void main(String[] argv) throws Exception {
    	PDFGraphics2D graphics = new PDFGraphics2D(new FileOutputStream("multi.pdf"), new Dimension(400, 600));
    	graphics.setMultiPage(true);

    	Font font = new Font("Serif", Font.PLAIN, 12);

    	graphics.startExport();
    	graphics.setHeader(font,
    			   new TagString("TEST DOCUMENT"),
    			   null,
    			   new TagString("<i>Multipage</i>"),
    			   1);
    	graphics.setFooter(font,
    			   null,
    			   new TagString("- %P% -"),
    			   null,
    			   -1);

    	graphics.openPage(new Dimension(200, 400), "Page 1");
    	graphics.setColor(Color.black);
    	graphics.setFont(font);
    	graphics.drawRect(50, 100, 150, 20);
    	graphics.drawString("Page 1", 60., 115);
    	graphics.closePage();

    	graphics.openPage(new Dimension(200, 400), "Page 2");
    	graphics.setColor(Color.black);
    	graphics.setFont(new Font("SansSerif", Font.PLAIN, 12));
    	graphics.drawRect(50, 100, 150, 20);
    	graphics.drawString("Page 2", 60., 115);
    	graphics.drawString(new TagString("This is <tt>Page 2</tt> of 2"), 40.,150);
    	graphics.closePage();

    	graphics.endExport();

    	System.exit(0);
    }
}