Class PdfWriter.PdfBody
java.lang.Object
com.itextpdf.text.pdf.PdfWriter.PdfBody
- Enclosing class:
PdfWriter
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classPdfCrossReferenceis an entry in the PDF Cross-Reference table. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected ByteBufferprotected intprivate static final intprotected longthe current byte position in the body.protected intprotected ByteBufferprotected final PdfWriterprotected final TreeSet<PdfWriter.PdfBody.PdfCrossReference> array containing the cross-reference table of the normal objects. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) PdfIndirectObjectAdds aPdfObjectto the body.(package private) PdfIndirectObject(package private) PdfIndirectObjectprotected PdfIndirectObject(package private) PdfIndirectObjectadd(PdfObject object, PdfIndirectReference ref) Adds aPdfObjectto the body given an already existing PdfIndirectReference.(package private) PdfIndirectObjectadd(PdfObject object, PdfIndirectReference ref, boolean inObjStm) protected PdfWriter.PdfBody.PdfCrossReferenceaddToObjStm(PdfObject obj, int nObj) voidprotected intGets a PdfIndirectReference for an object that will be created in the future.longoffset()Returns the offset of the Cross-Reference table.(package private) voidsetRefnum(int refnum) intsize()Returns the total number of objects contained in the CrossReferenceTable of thisBody.protected voidwrite(PdfIndirectObject indirect, int refNumber) protected voidwrite(PdfIndirectObject indirect, int refNumber, int generation) voidwriteCrossReferenceTable(OutputStream os, PdfIndirectReference root, PdfIndirectReference info, PdfIndirectReference encryption, PdfObject fileID, long prevxref) Returns the CrossReferenceTable of theBody.
-
Field Details
-
OBJSINSTREAM
private static final int OBJSINSTREAM- See Also:
-
xrefs
array containing the cross-reference table of the normal objects. -
refnum
protected int refnum -
position
protected long positionthe current byte position in the body. -
writer
-
index
-
streamObjects
-
currentObjNum
protected int currentObjNum -
numObj
protected int numObj
-
-
Constructor Details
-
PdfBody
-
-
Method Details
-
setRefnum
void setRefnum(int refnum) -
addToObjStm
protected PdfWriter.PdfBody.PdfCrossReference addToObjStm(PdfObject obj, int nObj) throws IOException - Throws:
IOException
-
flushObjStm
- Throws:
IOException
-
add
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:
IOException
-
add
- Throws:
IOException
-
getPdfIndirectReference
Gets a PdfIndirectReference for an object that will be created in the future.- Returns:
- a PdfIndirectReference
-
getIndirectReferenceNumber
protected int getIndirectReferenceNumber() -
add
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:
IOException
-
add
PdfIndirectObject add(PdfObject object, PdfIndirectReference ref, boolean inObjStm) throws IOException - Throws:
IOException
-
add
- Throws:
IOException
-
add
protected PdfIndirectObject add(PdfObject object, int refNumber, int generation, boolean inObjStm) throws IOException - Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
offset
public long offset()Returns the offset of the Cross-Reference table.- Returns:
- an offset
-
size
public int size()Returns the total number of objects contained in the CrossReferenceTable of thisBody.- Returns:
- a number of objects
-
writeCrossReferenceTable
public void writeCrossReferenceTable(OutputStream os, PdfIndirectReference root, PdfIndirectReference info, PdfIndirectReference encryption, PdfObject fileID, long prevxref) throws IOException Returns the CrossReferenceTable of theBody.- Parameters:
os-root-info-encryption-fileID-prevxref-- Throws:
IOException
-