Class COSWriterObjectStream

java.lang.Object
org.apache.pdfbox.pdfwriter.compress.COSWriterObjectStream

public class COSWriterObjectStream extends Object
An instance of this class represents an object stream, that compresses a number of COSObjects in a stream. It may be added to the top level container of a written PDF document in place of the compressed objects. The document's PDFXRefStream must be adapted accordingly.
  • Field Details

    • LOG

      private static final org.apache.commons.logging.Log LOG
    • compressionPool

      private final COSWriterCompressionPool compressionPool
    • preparedKeys

      private final List<COSObjectKey> preparedKeys
    • preparedObjects

      private final List<COSBase> preparedObjects
  • Constructor Details

  • Method Details

    • prepareStreamObject

      public void prepareStreamObject(COSObjectKey key, COSBase object)
      Prepares the given COSObject to be written to this object stream, using the given COSObjectKey as it's ID for indirect references.
      Parameters:
      key - The COSObjectKey, that shall be used for indirect references to the COSObject.
      object - The COSObject, that shall be written to this object stream.
    • getPreparedKeys

      public List<COSObjectKey> getPreparedKeys()
      Returns all COSObjectKeys, that shall be added to the object stream, when writeObjectsToStream(COSStream) is called.
      Returns:
      All COSObjectKeys, that shall be added to the object stream.
    • writeObjectsToStream

      public COSStream writeObjectsToStream(COSStream stream) throws IOException
      Writes all prepared COSObjects to the given COSStream.
      Parameters:
      stream - The stream for the compressed objects.
      Returns:
      The given COSStream of this object stream.
      Throws:
      IOException - Shall be thrown, if writing the object stream failed.
    • writeObject

      private void writeObject(OutputStream output, COSBase object, boolean topLevel) throws IOException
      This method prepares and writes COS data to the object stream by selecting appropriate specialized methods for the content.
      Parameters:
      output - The stream, that shall be written to.
      object - The content, that shall be written.
      topLevel - True, if the currently written object is a top level entry of this object stream.
      Throws:
      IOException - Shall be thrown, when an exception occurred for the write operation.
    • writeCOSString

      private void writeCOSString(OutputStream output, COSString cosString) throws IOException
      Write the given COSString to the given stream.
      Parameters:
      output - The stream, that shall be written to.
      cosString - The content, that shall be written.
      Throws:
      IOException
    • writeCOSFloat

      private void writeCOSFloat(OutputStream output, COSFloat cosFloat) throws IOException
      Write the given COSFloat to the given stream.
      Parameters:
      output - The stream, that shall be written to.
      cosFloat - The content, that shall be written.
      Throws:
      IOException
    • writeCOSInteger

      private void writeCOSInteger(OutputStream output, COSInteger cosInteger) throws IOException
      Write the given COSInteger to the given stream.
      Parameters:
      output - The stream, that shall be written to.
      cosInteger - The content, that shall be written.
      Throws:
      IOException
    • writeCOSBoolean

      private void writeCOSBoolean(OutputStream output, COSBoolean cosBoolean) throws IOException
      Write the given COSBoolean to the given stream.
      Parameters:
      output - The stream, that shall be written to.
      cosBoolean - The content, that shall be written.
      Throws:
      IOException
    • writeCOSName

      private void writeCOSName(OutputStream output, COSName cosName) throws IOException
      Write the given COSName to the given stream.
      Parameters:
      output - The stream, that shall be written to.
      cosName - The content, that shall be written.
      Throws:
      IOException
    • writeCOSArray

      private void writeCOSArray(OutputStream output, COSArray cosArray) throws IOException
      Write the given COSArray to the given stream.
      Parameters:
      output - The stream, that shall be written to.
      cosArray - The content, that shall be written.
      Throws:
      IOException
    • writeCOSDictionary

      private void writeCOSDictionary(OutputStream output, COSDictionary cosDictionary) throws IOException
      Write the given COSDictionary to the given stream.
      Parameters:
      output - The stream, that shall be written to.
      cosDictionary - The content, that shall be written.
      Throws:
      IOException
    • writeObjectReference

      private void writeObjectReference(OutputStream output, COSObjectKey indirectReference) throws IOException
      Write the given COSObjectKey to the given stream.
      Parameters:
      output - The stream, that shall be written to.
      indirectReference - The content, that shall be written.
      Throws:
      IOException
    • writeCOSNull

      private void writeCOSNull(OutputStream output) throws IOException
      Write COSNull to the given stream.
      Parameters:
      output - The stream, that shall be written to.
      Throws:
      IOException