Package com.aowagie.text.pdf
Class PdfWriter.PdfBody
- java.lang.Object
-
- com.aowagie.text.pdf.PdfWriter.PdfBody
-
- Enclosing class:
- PdfWriter
static class PdfWriter.PdfBody extends java.lang.ObjectThis 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
Nested Classes Modifier and Type Class Description private static classPdfWriter.PdfBody.PdfCrossReferencePdfCrossReferenceis an entry in the PDF Cross-Reference table.
-
Field Summary
Fields Modifier and Type Field Description private intcurrentObjNumprivate ByteBufferindexprivate intnumObjprivate static intOBJSINSTREAMprivate intpositionthe current byte position in the body.private intrefnumprivate ByteBufferstreamObjectsprivate PdfWriterwriterprivate java.util.TreeSetxrefsarray containing the cross-reference table of the normal objects.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) PdfIndirectObjectadd(PdfObject object)Adds aPdfObjectto the body.private PdfIndirectObjectadd(PdfObject object, boolean inObjStm)private PdfIndirectObjectadd(PdfObject object, int refNumber)private PdfIndirectObjectadd(PdfObject object, int refNumber, boolean inObjStm)(package private) PdfIndirectObjectadd(PdfObject object, PdfIndirectReference ref)Adds aPdfObjectto the body given an already existing PdfIndirectReference.private PdfIndirectObjectadd(PdfObject object, PdfIndirectReference ref, boolean inObjStm)private PdfWriter.PdfBody.PdfCrossReferenceaddToObjStm(PdfObject obj, int nObj)private voidflushObjStm()(package private) intgetIndirectReferenceNumber()(package private) PdfIndirectReferencegetPdfIndirectReference()Gets a PdfIndirectReference for an object that will be created in the future.(package private) intoffset()Returns the offset of the Cross-Reference table.(package private) voidsetRefnum(int refnum)(package private) intsize()Returns the total number of objects contained in the CrossReferenceTable of thisBody.(package private) voidwriteCrossReferenceTable(java.io.OutputStream os, PdfIndirectReference root, PdfIndirectReference info, PdfIndirectReference encryption, PdfObject fileID, int prevxref)Returns the CrossReferenceTable of theBody.
-
-
-
Field Detail
-
OBJSINSTREAM
private static final int OBJSINSTREAM
- See Also:
- Constant Field Values
-
xrefs
private final java.util.TreeSet xrefs
array containing the cross-reference table of the normal objects.
-
refnum
private int refnum
-
position
private int position
the current byte position in the body.
-
writer
private final PdfWriter writer
-
index
private ByteBuffer index
-
streamObjects
private ByteBuffer streamObjects
-
currentObjNum
private int currentObjNum
-
numObj
private int numObj
-
-
Constructor Detail
-
PdfBody
PdfBody(PdfWriter writer)
Constructs a newPdfBody.- Parameters:
writer-
-
-
Method Detail
-
setRefnum
void setRefnum(int refnum)
-
addToObjStm
private PdfWriter.PdfBody.PdfCrossReference addToObjStm(PdfObject obj, int nObj) throws java.io.IOException
- Throws:
java.io.IOException
-
flushObjStm
private void flushObjStm() throws java.io.IOException- Throws:
java.io.IOException
-
add
PdfIndirectObject add(PdfObject object) throws java.io.IOException
Adds aPdfObjectto the body.This methods creates a
PdfIndirectObjectwith a certain number, containing the givenPdfObject. It also adds aPdfCrossReferencefor this object to anArrayListthat will be used to build the Cross-reference Table.- Parameters:
object- aPdfObject- Returns:
- a
PdfIndirectObject - Throws:
java.io.IOException
-
add
private PdfIndirectObject add(PdfObject object, boolean inObjStm) throws java.io.IOException
- Throws:
java.io.IOException
-
getPdfIndirectReference
PdfIndirectReference getPdfIndirectReference()
Gets a PdfIndirectReference for an object that will be created in the future.- Returns:
- a PdfIndirectReference
-
getIndirectReferenceNumber
int getIndirectReferenceNumber()
-
add
PdfIndirectObject add(PdfObject object, PdfIndirectReference ref) throws java.io.IOException
Adds aPdfObjectto the body given an already existing PdfIndirectReference.This methods creates a
PdfIndirectObjectwith the number given byref, containing the givenPdfObject. It also adds aPdfCrossReferencefor this object to anArrayListthat will be used to build the Cross-reference Table.- Parameters:
object- aPdfObjectref- aPdfIndirectReference- Returns:
- a
PdfIndirectObject - Throws:
java.io.IOException
-
add
private PdfIndirectObject add(PdfObject object, PdfIndirectReference ref, boolean inObjStm) throws java.io.IOException
- Throws:
java.io.IOException
-
add
private PdfIndirectObject add(PdfObject object, int refNumber) throws java.io.IOException
- Throws:
java.io.IOException
-
add
private PdfIndirectObject add(PdfObject object, int refNumber, boolean inObjStm) throws java.io.IOException
- Throws:
java.io.IOException
-
offset
int offset()
Returns the offset of the Cross-Reference table.- Returns:
- an offset
-
size
int size()
Returns the total number of objects contained in the CrossReferenceTable of thisBody.- Returns:
- a number of objects
-
writeCrossReferenceTable
void writeCrossReferenceTable(java.io.OutputStream os, PdfIndirectReference root, PdfIndirectReference info, PdfIndirectReference encryption, PdfObject fileID, int prevxref) throws java.io.IOExceptionReturns the CrossReferenceTable of theBody.- Parameters:
os-root-info-encryption-fileID-prevxref-- Throws:
java.io.IOException
-
-