import com.stevesoft.phreida.*; import java.awt.*; import java.io.*; public class Test3 { public static void main(String[] args) throws Exception { // Create the graphics object. PGraphics pg = new PGraphics("test3.pdf",0,0,300,460); // This example creates an outline on the left. // We need to ask the PGraphics object for the Outline // object. Outline book = pg.getOutline(); // We can get Outline objects from other Outlines. Outline chapter = book.getOutline("Chapter 1"); // Determine how well font metrics work by breaking // up the string in different ways. Font f = new Font("Arial",Font.PLAIN,10); pg.setFont(f); FontMetrics fm = pg.getFontMetrics(f); int h = fm.getAscent()+fm.getDescent(); int lead = fm.getLeading(); String str = "Hello, world"; for(int i=1;i<=10;i++) { String msg = "Page: "+i; // We want the 2nd chapter to start with page 5. if(i == 5) chapter = book.getOutline("Chapter 2"); // Add this page to the outline using msg as a title. // The startpage commands begins a new page. chapter.add(pg.startPage(),msg); // Add some text to the page. pg.drawString(msg,lead+10,h+10); } // Finish pg.dispose(); // writes out file System.exit(0); // Graphics thread is running still } }