Package com.itextpdf.text.pdf
Class PdfWriter.PdfBody
- java.lang.Object
-
- com.itextpdf.text.pdf.PdfWriter.PdfBody
-
- Enclosing class:
- PdfWriter
public static class PdfWriter.PdfBody extends java.lang.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
Nested Classes Modifier and Type Class Description static class
PdfWriter.PdfBody.PdfCrossReference
PdfCrossReference
is an entry in the PDF Cross-Reference table.
-
Field Summary
Fields Modifier and Type Field Description protected int
currentObjNum
protected ByteBuffer
index
protected int
numObj
private static int
OBJSINSTREAM
protected long
position
the current byte position in the body.protected int
refnum
protected ByteBuffer
streamObjects
protected PdfWriter
writer
protected java.util.TreeSet<PdfWriter.PdfBody.PdfCrossReference>
xrefs
array containing the cross-reference table of the normal objects.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) PdfIndirectObject
add(PdfObject object)
Adds aPdfObject
to the body.(package private) PdfIndirectObject
add(PdfObject object, boolean inObjStm)
(package private) PdfIndirectObject
add(PdfObject object, int refNumber)
protected PdfIndirectObject
add(PdfObject object, int refNumber, int generation, boolean inObjStm)
(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
flushObjStm()
protected int
getIndirectReferenceNumber()
PdfIndirectReference
getPdfIndirectReference()
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(java.io.OutputStream os, PdfIndirectReference root, PdfIndirectReference info, PdfIndirectReference encryption, PdfObject fileID, long prevxref)
Returns the CrossReferenceTable of theBody
.
-
-
-
Field Detail
-
OBJSINSTREAM
private static final int OBJSINSTREAM
- See Also:
- Constant Field Values
-
xrefs
protected final java.util.TreeSet<PdfWriter.PdfBody.PdfCrossReference> xrefs
array containing the cross-reference table of the normal objects.
-
refnum
protected int refnum
-
position
protected long position
the current byte position in the body.
-
writer
protected final PdfWriter writer
-
index
protected ByteBuffer index
-
streamObjects
protected ByteBuffer streamObjects
-
currentObjNum
protected int currentObjNum
-
numObj
protected int numObj
-
-
Constructor Detail
-
PdfBody
protected PdfBody(PdfWriter writer)
Constructs a newPdfBody
.- Parameters:
writer
-
-
-
Method Detail
-
setRefnum
void setRefnum(int refnum)
-
addToObjStm
protected PdfWriter.PdfBody.PdfCrossReference addToObjStm(PdfObject obj, int nObj) throws java.io.IOException
- Throws:
java.io.IOException
-
flushObjStm
public void flushObjStm() throws java.io.IOException
- Throws:
java.io.IOException
-
add
PdfIndirectObject add(PdfObject object) throws java.io.IOException
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:
java.io.IOException
-
add
PdfIndirectObject add(PdfObject object, boolean inObjStm) throws java.io.IOException
- Throws:
java.io.IOException
-
getPdfIndirectReference
public PdfIndirectReference getPdfIndirectReference()
Gets a PdfIndirectReference for an object that will be created in the future.- Returns:
- a PdfIndirectReference
-
getIndirectReferenceNumber
protected int getIndirectReferenceNumber()
-
add
PdfIndirectObject add(PdfObject object, PdfIndirectReference ref) throws java.io.IOException
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:
java.io.IOException
-
add
PdfIndirectObject add(PdfObject object, PdfIndirectReference ref, boolean inObjStm) throws java.io.IOException
- Throws:
java.io.IOException
-
add
PdfIndirectObject add(PdfObject object, int refNumber) throws java.io.IOException
- Throws:
java.io.IOException
-
add
protected PdfIndirectObject add(PdfObject object, int refNumber, int generation, boolean inObjStm) throws java.io.IOException
- Throws:
java.io.IOException
-
write
protected void write(PdfIndirectObject indirect, int refNumber) throws java.io.IOException
- Throws:
java.io.IOException
-
write
protected void write(PdfIndirectObject indirect, int refNumber, int generation) throws java.io.IOException
- Throws:
java.io.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(java.io.OutputStream os, PdfIndirectReference root, PdfIndirectReference info, PdfIndirectReference encryption, PdfObject fileID, long prevxref) throws java.io.IOException
Returns the CrossReferenceTable of theBody
.- Parameters:
os
-root
-info
-encryption
-fileID
-prevxref
-- Throws:
java.io.IOException
-
-