com.lowagie.text.pdf

Class PdfWriter.PdfBody

public static class PdfWriter.PdfBody extends Object

This class generates the structure of a PDF document.

This class covers the third section of Chapter 5 in the 'Portable Document Format Reference Manual version 1.3' (page 55-60). It contains the body of a PDF document (section 5.14) and it can also generate a Cross-reference Table (section 5.15).

See Also: PdfWriter PdfObject PdfIndirectObject

Nested Class Summary
static classPdfWriter.PdfBody.PdfCrossReference
PdfCrossReference is an entry in the PDF Cross-Reference table.
Field Summary
intcurrentObjNum
ByteBufferindex
intnumObj
static intOBJSINSTREAM
intposition
the current byte position in the body.
intrefnum
ByteBufferstreamObjects
PdfWriterwriter
TreeSetxrefs
array containing the cross-reference table of the normal objects.
Constructor Summary
PdfBody(PdfWriter writer)
Constructs a new PdfBody.
Method Summary
PdfIndirectObjectadd(PdfObject object)
Adds a PdfObject to the body.
PdfIndirectObjectadd(PdfObject object, boolean inObjStm)
PdfIndirectObjectadd(PdfObject object, PdfIndirectReference ref)
Adds a PdfObject to the body given an already existing PdfIndirectReference.
PdfIndirectObjectadd(PdfObject object, PdfIndirectReference ref, boolean inObjStm)
PdfIndirectObjectadd(PdfObject object, int refNumber)
PdfIndirectObjectadd(PdfObject object, int refNumber, boolean inObjStm)
PdfWriter.PdfBody.PdfCrossReferenceaddToObjStm(PdfObject obj, int nObj)
voidflushObjStm()
intgetIndirectReferenceNumber()
PdfIndirectReferencegetPdfIndirectReference()
Gets a PdfIndirectReference for an object that will be created in the future.
intoffset()
Returns the offset of the Cross-Reference table.
voidsetRefnum(int refnum)
intsize()
Returns the total number of objects contained in the CrossReferenceTable of this Body.
voidwriteCrossReferenceTable(OutputStream os, PdfIndirectReference root, PdfIndirectReference info, PdfIndirectReference encryption, PdfObject fileID, int prevxref)
Returns the CrossReferenceTable of the Body.

Field Detail

currentObjNum

private int currentObjNum

index

private ByteBuffer index

numObj

private int numObj

OBJSINSTREAM

private static final int OBJSINSTREAM

position

private int position
the current byte position in the body.

refnum

private int refnum

streamObjects

private ByteBuffer streamObjects

writer

private PdfWriter writer

xrefs

private TreeSet xrefs
array containing the cross-reference table of the normal objects.

Constructor Detail

PdfBody

PdfBody(PdfWriter writer)
Constructs a new PdfBody.

Parameters: writer

Method Detail

add

PdfIndirectObject add(PdfObject object)
Adds a PdfObject to the body.

This methods creates a PdfIndirectObject with a certain number, containing the given PdfObject. It also adds a PdfCrossReference for this object to an ArrayList that will be used to build the Cross-reference Table.

Parameters: object a PdfObject

Returns: a PdfIndirectObject

Throws: IOException

add

PdfIndirectObject add(PdfObject object, boolean inObjStm)

add

PdfIndirectObject add(PdfObject object, PdfIndirectReference ref)
Adds a PdfObject to the body given an already existing PdfIndirectReference.

This methods creates a PdfIndirectObject with the number given by ref, containing the given PdfObject. It also adds a PdfCrossReference for this object to an ArrayList that will be used to build the Cross-reference Table.

Parameters: object a PdfObject ref a PdfIndirectReference

Returns: a PdfIndirectObject

Throws: IOException

add

PdfIndirectObject add(PdfObject object, PdfIndirectReference ref, boolean inObjStm)

add

PdfIndirectObject add(PdfObject object, int refNumber)

add

PdfIndirectObject add(PdfObject object, int refNumber, boolean inObjStm)

addToObjStm

private PdfWriter.PdfBody.PdfCrossReference addToObjStm(PdfObject obj, int nObj)

flushObjStm

private void flushObjStm()

getIndirectReferenceNumber

int getIndirectReferenceNumber()

getPdfIndirectReference

PdfIndirectReference getPdfIndirectReference()
Gets a PdfIndirectReference for an object that will be created in the future.

Returns: a PdfIndirectReference

offset

int offset()
Returns the offset of the Cross-Reference table.

Returns: an offset

setRefnum

void setRefnum(int refnum)

size

int size()
Returns the total number of objects contained in the CrossReferenceTable of this Body.

Returns: a number of objects

writeCrossReferenceTable

void writeCrossReferenceTable(OutputStream os, PdfIndirectReference root, PdfIndirectReference info, PdfIndirectReference encryption, PdfObject fileID, int prevxref)
Returns the CrossReferenceTable of the Body.

Parameters: os root info encryption fileID prevxref

Throws: IOException