com.etymon.pjx
Class PdfWriter

java.lang.Object
  extended by com.etymon.pjx.PdfWriter

public final class PdfWriter
extends java.lang.Object

Writes a PDF document. Most applications do not need to access methods in this class but should instead go through PdfManager. This class is synchronized.


Field Summary
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 Summary
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.
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_bos

protected java.io.BufferedOutputStream _bos
The buffered output stream associated with the PDF document.


_dos

protected java.io.DataOutputStream _dos
The data output stream associated with the PDF document.


_fc

protected java.nio.channels.FileChannel _fc
The file channel associated with the PDF document.


_fos

protected java.io.FileOutputStream _fos
The file output stream associated with the PDF document.


PDF_HEADER

protected static final java.lang.String PDF_HEADER
The header to write at the beginning of PDF files.

See Also:
Constant Field Values

PDF_VERSION

protected static final java.lang.String PDF_VERSION
The PDF version output by this package.

See Also:
Constant Field Values
Constructor Detail

PdfWriter

public PdfWriter(java.io.File pdfFile)
          throws java.io.IOException
Creates a writer for a PDF document to be written to a file. If the file exists, this constructor overwrites it.

Parameters:
pdfFile - the file to write the PDF document to.
Throws:
java.io.IOException

PdfWriter

public PdfWriter(java.io.OutputStream outputStream)
          throws java.io.IOException
Creates a writer for a PDF document to be written to an OutputStream. The calling method should ensure that the specified stream is a buffered stream, if applicable.

Parameters:
outputStream - the stream to write the PDF document to.
Throws:
java.io.IOException
Method Detail

close

public void close()
           throws java.io.IOException
Closes the PDF document and releases any system resources associated with it.

Throws:
java.io.IOException

getDataOutputStream

protected java.io.DataOutputStream getDataOutputStream()
Returns the data output stream associated with this writer.

Returns:
the data output stream.

getFileChannel

protected java.nio.channels.FileChannel getFileChannel()
Returns the file channel associated with this writer.

Returns:
the file channel.

writeByteBuffer

protected int writeByteBuffer(java.nio.ByteBuffer byteBuffer)
                       throws java.io.IOException
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.

Writes the contents of a ByteBuffer to the PDF document. The entire capacity of the buffer is written, disregarding its position and limit.

Returns:
the number of bytes written.
Throws:
java.io.IOException

writeCopy

public long writeCopy(PdfReader reader)
               throws java.io.IOException
Writes an entire PDF document stream to the output PDF document. This is used for incremental update.

Parameters:
reader - the source of the PDF document stream.
Returns:
the number of bytes written.
Throws:
java.io.IOException

writeHeader

public int writeHeader()
                throws java.io.IOException
Writes a PDF header to the document.

Returns:
the number of bytes written.
Throws:
java.io.IOException

writeObject

public int writeObject(PdfObject obj,
                       int number,
                       int generation)
                throws java.io.IOException
Writes a PDF object to the document as an indirect object.

Parameters:
obj - the object to write.
number - the object number.
generation - the generation number.
Returns:
the number of bytes written.
Throws:
java.io.IOException

writeObjectIndirect

public int writeObjectIndirect(PdfObject obj,
                               int number,
                               int generation)
                        throws java.io.IOException
Writes a PDF object to the document as an indirect object.

Parameters:
obj - the object to write.
number - the object number.
generation - the generation number.
Returns:
the number of bytes written.
Throws:
java.io.IOException

writeXrefTable

public int writeXrefTable(XrefTable xt,
                          long startxref)
                   throws java.io.IOException
Writes a cross-reference table (and associated trailer) to the document.

Parameters:
xt - the cross-reference table.
startxref - the file offset of the beginning of the cross-reference table.
Returns:
the number of bytes written.
Throws:
java.io.IOException