Class COSWriterCompressionPool

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

public class COSWriterCompressionPool extends Object
An instance of this class compresses the contents of a given PDDocument.
Author:
Christian Appl
  • Field Details

    • MINIMUM_SUPPORTED_VERSION

      public static final float MINIMUM_SUPPORTED_VERSION
      See Also:
  • Constructor Details

    • COSWriterCompressionPool

      public COSWriterCompressionPool(PDDocument document, CompressParameters parameters) throws IOException

      Constructs an object that can be used to compress the contents of a given PDDocument. It provides the means to:

      Parameters:
      document - The document, that shall be compressed.
      parameters - The configuration of the compression operations, that shall be applied.
      Throws:
      IOException - Shall be thrown if a compression operation failed.
  • Method Details

    • getTopLevelObjects

      public List<COSObjectKey> getTopLevelObjects()
      Returns all COSBases, that must be added to the document's top level container. Those objects are not valid to be added to an object stream.
      Returns:
      A list of all top level COSBases.
    • getObjectStreamObjects

      public List<COSObjectKey> getObjectStreamObjects()
      Returns all COSBases that can be appended to an object stream. This list is only provided to enable reflections. Contained objects should indeed be added to a compressed document via an object stream, as can be created via calling: createObjectStreams()
      Returns:
      A list of all COSBases, that can be added to an object stream.
    • contains

      public boolean contains(COSBase object)
      Returns true, if the given COSBase is a registered object of this compression pool.
      Parameters:
      object - The object, that shall be checked.
      Returns:
      True, if the given COSBase is a registered object of this compression pool.
    • getKey

      public COSObjectKey getKey(COSBase object)
      Returns the COSObjectKey, that is registered for the given COSBase in this compression pool.
      Parameters:
      object - The COSBase a COSObjectKey is registered for in this compression pool.
      Returns:
      The COSObjectKey, that is registered for the given COSBase in this compression pool, if such an object is contained.
    • getObject

      public COSBase getObject(COSObjectKey key)
      Returns the COSBase, that is registered for the given COSObjectKey in this compression pool.
      Parameters:
      key - The COSObjectKey a COSBase is registered for in this compression pool.
      Returns:
      The COSBase, that is registered for the given COSObjectKey in this compression pool, if such an object is contained.
    • getHighestXRefObjectNumber

      public long getHighestXRefObjectNumber()
      Returns the highest object number, that is registered in this compression pool.
      Returns:
      The highest object number, that is registered in this compression pool.
    • createObjectStreams

      public List<COSWriterObjectStream> createObjectStreams()
      Creates COSWriterObjectStreams for all currently registered objects of this pool, that have been marked as fit for being compressed in this manner. Such object streams may be added to a PDF document and shall be declared in a document's PDFXRefStream accordingly. The objects contained in such a stream must not be added to the document separately.
      Returns:
      The created COSWriterObjectStreams for all currently registered compressible objects.