Package pdf

Class PDFOutput


  • public class PDFOutput
    extends java.lang.Object
    This class is used to write a PDF document. It acts as a wrapper to a real OutputStream, but is necessary for certain internal PDF structures to be built correctly.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.io.ByteArrayOutputStream baos
      This is the OutputStream used to write each object to.
      protected PDFObject infoID
      This is used to track the /Info object (info)
      protected int offset
      This is the current position within the stream
      protected java.util.Vector<PDFXref> offsets
      This vector contains offsets of each object
      protected java.io.OutputStream os
      This is the actual OutputStream used to write to.
      protected PDFObject rootID
      This is used to track the /Root object (catalog)
    • Constructor Summary

      Constructors 
      Constructor Description
      PDFOutput​(java.io.OutputStream os)
      This creates a PDF OutputStream
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void close()
      This closes the Stream, writing the xref table
      protected void write​(PDFObject ob)
      This method writes a PDFObject to the stream.
      protected void writeblock​(int firstid, java.util.Vector<PDFXref> block)
      Writes a block of references to the PDF file
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • os

        protected java.io.OutputStream os
        This is the actual OutputStream used to write to.
      • baos

        protected java.io.ByteArrayOutputStream baos
        This is the OutputStream used to write each object to.

        We use a separate stream, because we need to keep track of how many bytes have been written for each object for the xref table to work correctly.

      • offset

        protected int offset
        This is the current position within the stream
      • offsets

        protected java.util.Vector<PDFXref> offsets
        This vector contains offsets of each object
      • rootID

        protected PDFObject rootID
        This is used to track the /Root object (catalog)
      • infoID

        protected PDFObject infoID
        This is used to track the /Info object (info)
    • Constructor Detail

      • PDFOutput

        public PDFOutput​(java.io.OutputStream os)
                  throws java.io.IOException
        This creates a PDF OutputStream
        Parameters:
        os - The output stream to write the PDF file to.
        Throws:
        java.io.IOException - if there is an I/O error.
    • Method Detail

      • write

        protected void write​(PDFObject ob)
                      throws java.io.IOException
        This method writes a PDFObject to the stream.
        Parameters:
        ob - PDFObject Obeject to write
        Throws:
        java.io.IOException - on error
      • close

        protected void close()
                      throws java.io.IOException
        This closes the Stream, writing the xref table
        Throws:
        java.io.IOException
      • writeblock

        protected void writeblock​(int firstid,
                                  java.util.Vector<PDFXref> block)
                           throws java.io.IOException
        Writes a block of references to the PDF file
        Parameters:
        firstid - ID of the first reference in this block
        block - Vector containing the references in this block
        Throws:
        java.io.IOException - on write error