FileDocCategorySizeDatePackage
Page.javaAPI DocExample1324Mon Jul 03 20:16:02 BST 2000com.darwinsys.spdf

Page

public class Page extends PDFDict
Represent one Page of a PDF file.

Fields Summary
protected ArrayList
objects
Constructors Summary
public Page(PDF m)


	   
		super(m);
		dict.put("Type", "/Page");
		dict.put("Parent", "4 0 R");
		dict.put("Resources", "<< /Font << /F1 8 0 R >> /ProcSet 7 0 R >>");
		dict.put("MediaBox", "[0 0 612 792]");
		dict.put("Contents", "6 0 R");
		
	
Methods Summary
public voidadd(PDFObject po)

		objects.add(po);
	
protected voidprint()
Print all the objects on the page. For now, just print all the Text objects, as one Stream.

		// Print the Page object
		super.print();

		// Now do the Text objects as one PDF obj
		master.addXref();
		startObj();

		StringBuffer sb = new StringBuffer();
		sb.append("BT\n");
		sb.append("/F1 12 Tf\n");

		for (int i=0; i<objects.size(); i++) {
			PDFObject po = (PDFObject)objects.get(i);
			if (po instanceof Text)
				((Text)po).print(sb);
			else if (po instanceof MoveTo)
				((MoveTo)po).print(sb);
			// else if (po instanceof Font)
			//	...
			else
				System.err.println("PDFPage: ignoring " + po);
		}
		sb.append("ET\n");

		master.println("<< /Length " + sb.length() + " >>");
		master.println("stream");
		master.print(sb);
		master.println("endstream");
		endObj();