|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.rosuda.util.PDFconstructor
public class PDFconstructor
This class provides means of constructing one-pass, basic, uncompressed PDF files. It is the lowest level (objects-level) of PDF construction. Reference index and trailer is created automatically. Output is written to a supplied PrintStream
.
Sample usage:
PDFconstructor p=new PDFconstructor(System.out,1); p.addObject("<< /Type /Catalog\n/Outlines 2 0 R\n/Pages 3 0 R\n>>"); // ID 1 document root p.addObject("<< /Type /Outlines\n/Count 0\n>>"); // ID 2 outlines p.addObject("<< /Type /Pages\n/Kids [4 0 R]\n/Count 1\n>>"); // ID 3 pages layout p.addObject("<< /Type /Page\n/Parent 3 0 R\n/MediaBox [0 0 612 792]\n/Contents 5 0 R\n/Resources << /ProcSet 6 0 R\n/Font << /F1 7 0 R >>\n>>\n>>"); // ID 4 page def. p.addObject(PDFconstructor.asStream("150 250 m\n150 350 l\nS\n4 w\n[4 6] 0 d\n150 250 m\n400 250 l\nS\n[] 0 d\n1 w\n1.0 0.0 0.0 RG\n0.5 0.75 1.0 rg\n200 300 50 75 re\nB 0.5 0.1 0.2 RG\n0.7 g\n300 300 m\n300 400 400 400 400 300 c\nb\nBT\n/F1 24 Tf\n100 100 Td\n(Hello World) Tj\nET")); // ID 5 contents p.addObject("[/PDF /Text]"); // ID 6 proc set p.addObject("<< /Type /Font\n/Subtype /Type1\n/Name /F1\n/BaseFont /Helvetica\n/Encoding /MacRomanEncoding\n>>"); // ID 7 fonts p.end(1);
Constructor Summary | |
---|---|
PDFconstructor(java.io.PrintStream os,
int pdfver)
begin construction of a new PDF file. |
Method Summary | |
---|---|
int |
addObject(java.lang.String s)
add the specified object to the PDF file. |
static java.lang.String |
asStream(java.lang.String s)
constructs a string that can be passed to addObject(java.lang.String) that represents a (non-compressed) PDF stream. |
int |
end(int root)
finish construction of the PDF file, add index/reference and trailer. |
void |
out(java.lang.String s)
add specified string to the stream output. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PDFconstructor(java.io.PrintStream os, int pdfver)
PDFconstructor(java.io.PrintStream, int)
is compatible from PDF 1.1 on, but the objects used may require higher PDF version. The creation is started immediately and PDF version string is sent to the output stream.Important! PDF files use absolute indexing, therefore the output stream should have no preceeding or trailing contents, otherwise the resulting file will be invalid! In plain text the PrintStream should be created and immediately passed to PDFcreator. Upon finish PDFcreator automatically closes the stream. No other methods than those of the PDFconstructor should be used on the stream.
os
- output streampdfver
- minor version of the PDF format used (major version is always 1). For example pdfver=2 corresponds to PDF-1.2Method Detail |
---|
public void out(java.lang.String s)
s
- string to be written to the streampublic int addObject(java.lang.String s)
s
- string containing the object to be added
public static java.lang.String asStream(java.lang.String s)
addObject(java.lang.String)
that represents a (non-compressed) PDF stream.
s
- string which will be encapsulated as the contants of the stream (such as graphics commands etc.) Trailing newline is added implicitely.
public int end(int root)
root
- ID of the root object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |