org.apache.pdfbox.pdfwriter.compress

## 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 Summary

Fields
`static float` `MINIMUM_SUPPORTED_VERSION`

### Constructor Summary

Constructors
Constructor and Description
`COSWriterCompressionPool(PDDocument document, CompressParameters parameters)` Constructs an object that can be used to compress the contents of a given `PDDocument`.

### Method Summary

All Methods Instance Methods Concrete Methods
`boolean` `contains(COSBase object)` Returns true, if the given `COSBase` is a registered object of this compression pool.
`List<COSWriterObjectStream>` `createObjectStreams()` Creates `COSWriterObjectStream`s for all currently registered objects of this pool, that have been marked as fit for being compressed in this manner.
`long` `getHighestXRefObjectNumber()` Returns the highest object number, that is registered in this compression pool.
`COSObjectKey` `getKey(COSBase object)` Returns the `COSObjectKey`, that is registered for the given `COSBase` in this compression pool.
`COSBase` `getObject(COSObjectKey key)` Returns the `COSBase`, that is registered for the given `COSObjectKey` in this compression pool.
`List<COSObjectKey>` `getObjectStreamObjects()` Returns all `COSBase`s that can be appended to an object stream.
`List<COSObjectKey>` `getTopLevelObjects()` Returns all `COSBase`s, that must be added to the document's top level container.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### MINIMUM_SUPPORTED_VERSION

    public static final float MINIMUM_SUPPORTED_VERSION

See Also:
  Constant Field Values

### Constructor Detail

#### 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:

- Compress the COSStructure of the document, by streaming `COSBase`s to compressed `COSWriterObjectStream`s

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 Detail

#### getTopLevelObjects

    public List<COSObjectKey> getTopLevelObjects()

Returns all `COSBase`s, 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 `COSBase`s.

#### getObjectStreamObjects

    public List<COSObjectKey> getObjectStreamObjects()

Returns all `COSBase`s 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 `COSBase`s, 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 `COSWriterObjectStream`s 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 `COSWriterObjectStream`s for all currently registered compressible objects.