Top Description Fields Constructors Methods
org.apache.pdfbox.pdfwriter.compress

public Class COSWriterObjectStream

extends Object
Class Inheritance
Imports
java.io.ByteArrayOutputStream, .IOException, .OutputStream, java.nio.charset.StandardCharsets, java.util.ArrayList, .Collections, .List, .Map, org.apache.commons.logging.Log, .LogFactory, org.apache.pdfbox.cos.COSArray, .COSBase, .COSBoolean, .COSDictionary, .COSFloat, .COSInteger, .COSName, .COSNull, .COSObject, .COSObjectKey, .COSStream, .COSString, org.apache.pdfbox.pdfparser.PDFXRefStream, org.apache.pdfbox.pdfwriter.COSWriter

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.
Author
Christian Appl

Field Summary

Modifier and TypeField and Description
private final COSWriterCompressionPool
private static final Log
private final List<COSObjectKey>
private final List<COSBase>

Constructor Summary

AccessConstructor and Description
public
COSWriterObjectStream(COSWriterCompressionPool
The compression pool an object stream shall be created for.
compressionPool
)

Creates an object stream for compressible objects from the given COSWriterCompressionPool.

Method Summary

Modifier and TypeMethod and Description
public List<COSObjectKey>

Returns:

All COSObjectKeys, that shall be added to the object stream.
getPreparedKeys
()

Returns all COSObjectKeys, that shall be added to the object stream, when COSWriterObjectStream#writeObjectsToStream(COSStream) is called.

public void
prepareStreamObject(COSObjectKey
The COSObjectKey, that shall be used for indirect references to the COSObject.
key
,
COSBase
The COSObject, that shall be written to this object stream.
object
)

Prepares the given COSObject to be written to this object stream, using the given COSObjectKey as it's ID for indirect references.

private void
writeCOSArray(OutputStream
The stream, that shall be written to.
output
,
COSArray
The content, that shall be written.
cosArray
)

Write the given COSArray to the given stream.

private void
writeCOSBoolean(OutputStream
The stream, that shall be written to.
output
,
COSBoolean
The content, that shall be written.
cosBoolean
)

Write the given COSBoolean to the given stream.

private void
writeCOSDictionary(OutputStream
The stream, that shall be written to.
output
,
COSDictionary
The content, that shall be written.
cosDictionary
)

Write the given COSDictionary to the given stream.

private void
writeCOSFloat(OutputStream
The stream, that shall be written to.
output
,
COSFloat
The content, that shall be written.
cosFloat
)

Write the given COSFloat to the given stream.

private void
writeCOSInteger(OutputStream
The stream, that shall be written to.
output
,
COSInteger
The content, that shall be written.
cosInteger
)

Write the given COSInteger to the given stream.

private void
writeCOSName(OutputStream
The stream, that shall be written to.
output
,
COSName
The content, that shall be written.
cosName
)

Write the given COSName to the given stream.

private void
writeCOSNull(OutputStream
The stream, that shall be written to.
output
)

Write COSNull to the given stream.

private void
writeCOSString(OutputStream
The stream, that shall be written to.
output
,
COSString
The content, that shall be written.
cosString
)

Write the given COSString to the given stream.

private void
writeObject(OutputStream
The stream, that shall be written to.
output
,
COSBase
The content, that shall be written.
object
,
boolean
True, if the currently written object is a top level entry of this object stream.
topLevel
)

This method prepares and writes COS data to the object stream by selecting appropriate specialized methods for the content.

private void
writeObjectReference(OutputStream
The stream, that shall be written to.
output
,
COSObjectKey
The content, that shall be written.
indirectReference
)

Write the given COSObjectKey to the given stream.

public COSStream

Returns:

The given COSStream of this object stream.
writeObjectsToStream
(COSStream
The stream for the compressed objects.
stream
)

Writes all prepared COSObjects to the given COSStream.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

compressionPoolback to summary
private final COSWriterCompressionPool compressionPool
LOGback to summary
private static final Log LOG
preparedKeysback to summary
private final List<COSObjectKey> preparedKeys
preparedObjectsback to summary
private final List<COSBase> preparedObjects

Constructor Detail

COSWriterObjectStreamback to summary
public COSWriterObjectStream(COSWriterCompressionPool compressionPool)

Creates an object stream for compressible objects from the given COSWriterCompressionPool. The objects must first be prepared for this object stream, by adding them via calling COSWriterObjectStream#prepareStreamObject(COSObjectKey, COSBase) and will be written to this COSStream, when COSWriterObjectStream#writeObjectsToStream(COSStream) is called.

Parameters
compressionPool:COSWriterCompressionPool

The compression pool an object stream shall be created for.

Method Detail

getPreparedKeysback to summary
public List<COSObjectKey> getPreparedKeys()

Returns all COSObjectKeys, that shall be added to the object stream, when COSWriterObjectStream#writeObjectsToStream(COSStream) is called.

Returns:List<COSObjectKey>

All COSObjectKeys, that shall be added to the object stream.

prepareStreamObjectback to summary
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:COSObjectKey

The COSObjectKey, that shall be used for indirect references to the COSObject.

object:COSBase

The COSObject, that shall be written to this object stream.

writeCOSArrayback to summary
private void writeCOSArray(OutputStream output, COSArray cosArray) throws IOException

Write the given COSArray to the given stream.

Parameters
output:OutputStream

The stream, that shall be written to.

cosArray:COSArray

The content, that shall be written.

writeCOSBooleanback to summary
private void writeCOSBoolean(OutputStream output, COSBoolean cosBoolean) throws IOException

Write the given COSBoolean to the given stream.

Parameters
output:OutputStream

The stream, that shall be written to.

cosBoolean:COSBoolean

The content, that shall be written.

writeCOSDictionaryback to summary
private void writeCOSDictionary(OutputStream output, COSDictionary cosDictionary) throws IOException

Write the given COSDictionary to the given stream.

Parameters
output:OutputStream

The stream, that shall be written to.

cosDictionary:COSDictionary

The content, that shall be written.

writeCOSFloatback to summary
private void writeCOSFloat(OutputStream output, COSFloat cosFloat) throws IOException

Write the given COSFloat to the given stream.

Parameters
output:OutputStream

The stream, that shall be written to.

cosFloat:COSFloat

The content, that shall be written.

writeCOSIntegerback to summary
private void writeCOSInteger(OutputStream output, COSInteger cosInteger) throws IOException

Write the given COSInteger to the given stream.

Parameters
output:OutputStream

The stream, that shall be written to.

cosInteger:COSInteger

The content, that shall be written.

writeCOSNameback to summary
private void writeCOSName(OutputStream output, COSName cosName) throws IOException

Write the given COSName to the given stream.

Parameters
output:OutputStream

The stream, that shall be written to.

cosName:COSName

The content, that shall be written.

writeCOSNullback to summary
private void writeCOSNull(OutputStream output) throws IOException

Write COSNull to the given stream.

Parameters
output:OutputStream

The stream, that shall be written to.

writeCOSStringback to summary
private void writeCOSString(OutputStream output, COSString cosString) throws IOException

Write the given COSString to the given stream.

Parameters
output:OutputStream

The stream, that shall be written to.

cosString:COSString

The content, that shall be written.

writeObjectback to summary
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:OutputStream

The stream, that shall be written to.

object:COSBase

The content, that shall be written.

topLevel:boolean

True, if the currently written object is a top level entry of this object stream.

Exceptions
IOException:
Shall be thrown, when an exception occurred for the write operation.
writeObjectReferenceback to summary
private void writeObjectReference(OutputStream output, COSObjectKey indirectReference) throws IOException

Write the given COSObjectKey to the given stream.

Parameters
output:OutputStream

The stream, that shall be written to.

indirectReference:COSObjectKey

The content, that shall be written.

writeObjectsToStreamback to summary
public COSStream writeObjectsToStream(COSStream stream) throws IOException

Writes all prepared COSObjects to the given COSStream.

Parameters
stream:COSStream

The stream for the compressed objects.

Returns:COSStream

The given COSStream of this object stream.

Exceptions
IOException:
Shall be thrown, if writing the object stream failed.