Package com.itextpdf.text.pdf
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 class
PdfCrossReference
is an entry in the PDF Cross-Reference table. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
protected ByteBuffer
protected int
private static final int
protected long
the current byte position in the body.protected int
protected ByteBuffer
protected final PdfWriter
protected 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) PdfIndirectObject
Adds aPdfObject
to the body.(package private) PdfIndirectObject
(package private) PdfIndirectObject
protected PdfIndirectObject
(package private) PdfIndirectObject
add
(PdfObject object, PdfIndirectReference ref) Adds aPdfObject
to the body given an already existing PdfIndirectReference.(package private) PdfIndirectObject
add
(PdfObject object, PdfIndirectReference ref, boolean inObjStm) protected PdfWriter.PdfBody.PdfCrossReference
addToObjStm
(PdfObject obj, int nObj) void
protected int
Gets a PdfIndirectReference for an object that will be created in the future.long
offset()
Returns the offset of the Cross-Reference table.(package private) void
setRefnum
(int refnum) int
size()
Returns the total number of objects contained in the CrossReferenceTable of thisBody
.protected void
write
(PdfIndirectObject indirect, int refNumber) protected void
write
(PdfIndirectObject indirect, int refNumber, int generation) void
writeCrossReferenceTable
(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
Constructs a newPdfBody
.- Parameters:
writer
-
-
-
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 aPdfObject
to the body.This methods creates a
PdfIndirectObject
with a certain number, containing the givenPdfObject
. It also adds aPdfCrossReference
for this object to anArrayList
that 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 aPdfObject
to the body given an already existing PdfIndirectReference.This methods creates a
PdfIndirectObject
with the number given byref
, containing the givenPdfObject
. It also adds aPdfCrossReference
for this object to anArrayList
that will be used to build the Cross-reference Table.- Parameters:
object
- aPdfObject
ref
- 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
-