public final class PdfWriter
extends java.lang.Object
PdfManager
. This class is synchronized.Modifier and Type | Field and Description |
---|---|
protected java.io.BufferedOutputStream |
_bos
The buffered output stream associated with the PDF document.
|
protected java.io.DataOutputStream |
_dos
The data output stream associated with the PDF document.
|
protected java.nio.channels.FileChannel |
_fc
The file channel associated with the PDF document.
|
protected java.io.FileOutputStream |
_fos
The file output stream associated with the PDF document.
|
protected static java.lang.String |
PDF_HEADER
The header to write at the beginning of PDF files.
|
protected static java.lang.String |
PDF_VERSION
The PDF version output by this package.
|
Constructor and Description |
---|
PdfWriter(java.io.File pdfFile)
Creates a writer for a PDF document to be written to a
file.
|
PdfWriter(java.io.OutputStream outputStream)
Creates a writer for a PDF document to be written to an
OutputStream . |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the PDF document and releases any system resources
associated with it.
|
protected java.io.DataOutputStream |
getDataOutputStream()
Returns the data output stream associated with this writer.
|
protected java.nio.channels.FileChannel |
getFileChannel()
Returns the file channel associated with this writer.
|
protected int |
writeByteBuffer(java.nio.ByteBuffer byteBuffer)
Deprecated.
It needs to be considered whether this method
should write the entire capacity of the buffer, if it is to
be made a public method.
|
long |
writeCopy(PdfReader reader)
Writes an entire PDF document stream to the output PDF
document.
|
int |
writeHeader()
Writes a PDF header to the document.
|
int |
writeObject(PdfObject obj,
int number,
int generation)
Writes a PDF object to the document as an indirect object.
|
int |
writeObjectIndirect(PdfObject obj,
int number,
int generation)
Writes a PDF object to the document as an indirect object.
|
int |
writeXrefTable(XrefTable xt,
long startxref)
Writes a cross-reference table (and associated trailer) to
the document.
|
protected java.io.BufferedOutputStream _bos
protected java.io.DataOutputStream _dos
protected java.nio.channels.FileChannel _fc
protected java.io.FileOutputStream _fos
protected static final java.lang.String PDF_HEADER
protected static final java.lang.String PDF_VERSION
public PdfWriter(java.io.File pdfFile) throws java.io.IOException
pdfFile
- the file to write the PDF document to.java.io.IOException
public PdfWriter(java.io.OutputStream outputStream) throws java.io.IOException
OutputStream
. The calling method should
ensure that the specified stream is a buffered stream, if
applicable.outputStream
- the stream to write the PDF document to.java.io.IOException
public void close() throws java.io.IOException
java.io.IOException
protected java.io.DataOutputStream getDataOutputStream()
protected java.nio.channels.FileChannel getFileChannel()
protected int writeByteBuffer(java.nio.ByteBuffer byteBuffer) throws java.io.IOException
ByteBuffer
to the PDF
document. The entire capacity of the buffer is written,
disregarding its position and limit.java.io.IOException
public long writeCopy(PdfReader reader) throws java.io.IOException
reader
- the source of the PDF document stream.java.io.IOException
public int writeHeader() throws java.io.IOException
java.io.IOException
public int writeObject(PdfObject obj, int number, int generation) throws java.io.IOException
obj
- the object to write.number
- the object number.generation
- the generation number.java.io.IOException
public int writeObjectIndirect(PdfObject obj, int number, int generation) throws java.io.IOException
obj
- the object to write.number
- the object number.generation
- the generation number.java.io.IOException
public int writeXrefTable(XrefTable xt, long startxref) throws java.io.IOException
xt
- the cross-reference table.startxref
- the file offset of the beginning of the
cross-reference table.java.io.IOException