Methods Summary |
---|
public void | add(Page p)
pages.add(p);
|
protected void | addXref()Add an entry into the offset table
xrefs.add(new Long(offset));
|
public void | insertPage(int where, Page p)
pages.add(where, p);
|
protected void | print(java.lang.String s)Print a String
out.print(s);
offset += s.length();
|
protected void | print(java.lang.Object o)Print an Object
print(o.toString());
|
protected void | print(int i)Print an int
String s = Integer.toString(i);
print(s);
|
protected void | printXref(long n, int where, char inUse)Write one Xref, in the format 0000000000 65535 f
println(nf10.format(n) + " " + nf5.format(where) + " " + inUse);
|
protected void | println()Println with no args
print("\n");
|
protected void | println(java.lang.String s)Println a String
print(s);
print("\n");
|
protected void | println(java.lang.Object o)Println an Object
println(o.toString());
|
protected void | println(int i)Println an int
String s = Integer.toString(i);
print(s);
|
public void | setAuthor(java.lang.String au)
infoObj.dict.put("Author", "(" + au + ")");
|
public void | writePDF()Write the entire output
if (startedWriting) {
throw new IllegalStateException(
"writePDF() can only be called once.");
}
startedWriting = true;
writePDFHeader();
writePDFbody();
writeXrefs();
writePDFTrailer();
out.flush();
out.close();
|
protected void | writePDFHeader()
println(PDF_MAGIC);
rootObj.print(); // 1
infoObj.print(); // 2
outlinesObj.print(); // 3
pagesObj.print(); // 4
|
protected void | writePDFTrailer()
println("trailer");
println("<<");
println("/Size " + (xrefs.size() + 1));
println("/Root 1 0 R");
println("/Info 2 0 R");
println(">>");
println("% startxref");
println("% " + xrefStart);
println("%%EOF");
|
protected void | writePDFbody()
for (int i=0; i<pages.size(); i++) {
((Page)pages.get(i)).print(); // 5, 6
}
addXref();
print(currObj++); println(" 0 obj");
println("[/PDF /Text]");
println("endobj");
fontDict.print(); // 8
|
protected void | writeXrefs()Write all the xrefs, using the format above
xrefStart = offset;
println("xref");
print(0);
print(" ");
print(xrefs.size() + 1);
println();
// "fake" entry at 0, always 0, -1, f(free).
printXref(0, 65535, 'f");
// Remaining xref entries are for real objects.
for (int i=0; i<xrefs.size(); i++) {
Long lo = (Long)xrefs.get(i);
long l = lo.longValue();
printXref(l, 0, 'n");
}
|