Class COSWriterObjectStream
java.lang.Object
org.apache.pdfbox.pdfwriter.compress.COSWriterObjectStream
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classReuse the underlying byte array instead of copying it. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final COSWriterCompressionPoolprivate static final org.apache.commons.logging.Logprivate final List<COSObjectKey> -
Constructor Summary
ConstructorsConstructorDescriptionCOSWriterObjectStream(COSWriterCompressionPool compressionPool) Creates an object stream for compressible objects from the givenCOSWriterCompressionPool. -
Method Summary
Modifier and TypeMethodDescriptionReturns allCOSObjectKeys, that shall be added to the object stream, whenwriteObjectsToStream(COSStream)is called.voidprepareStreamObject(COSObjectKey key, COSBase object) Prepares the givenCOSObjectto be written to this object stream, using the givenCOSObjectKeyas it's ID for indirect references.private voidwriteCOSArray(OutputStream output, COSArray cosArray) Write the givenCOSArrayto the given stream.private voidwriteCOSBoolean(OutputStream output, COSBoolean cosBoolean) Write the givenCOSBooleanto the given stream.private voidwriteCOSDictionary(OutputStream output, COSDictionary cosDictionary) Write the givenCOSDictionaryto the given stream.private voidwriteCOSFloat(OutputStream output, COSFloat cosFloat) Write the givenCOSFloatto the given stream.private voidwriteCOSInteger(OutputStream output, COSInteger cosInteger) Write the givenCOSIntegerto the given stream.private voidwriteCOSName(OutputStream output, COSName cosName) Write the givenCOSNameto the given stream.private voidwriteCOSNull(OutputStream output) WriteCOSNullto the given stream.private voidwriteCOSString(OutputStream output, COSString cosString) Write the givenCOSStringto the given stream.private voidwriteObject(OutputStream output, COSBase object, boolean topLevel) This method prepares and writes COS data to the object stream by selecting appropriate specialized methods for the content.private voidwriteObjectReference(OutputStream output, COSObjectKey indirectReference) Write the givenCOSObjectKeyto the given stream.writeObjectsToStream(COSStream stream)
-
Field Details
-
LOG
private static final org.apache.commons.logging.Log LOG -
compressionPool
-
preparedKeys
-
preparedObjects
-
-
Constructor Details
-
COSWriterObjectStream
Creates an object stream for compressible objects from the givenCOSWriterCompressionPool. The objects must first be prepared for this object stream, by adding them via callingprepareStreamObject(COSObjectKey, COSBase)and will be written to thisCOSStream, whenwriteObjectsToStream(COSStream)is called.- Parameters:
compressionPool- The compression pool an object stream shall be created for.
-
-
Method Details
-
prepareStreamObject
Prepares the givenCOSObjectto be written to this object stream, using the givenCOSObjectKeyas it's ID for indirect references.- Parameters:
key- TheCOSObjectKey, that shall be used for indirect references to theCOSObject.object- TheCOSObject, that shall be written to this object stream.
-
getPreparedKeys
Returns allCOSObjectKeys, that shall be added to the object stream, whenwriteObjectsToStream(COSStream)is called.- Returns:
- All
COSObjectKeys, that shall be added to the object stream.
-
writeObjectsToStream
- Parameters:
stream- The stream for the compressed objects.- Returns:
- The given
COSStreamof this object stream. - Throws:
IOException- Shall be thrown, if writing the object stream failed.
-
writeObject
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
Write the givenCOSStringto the given stream.- Parameters:
output- The stream, that shall be written to.cosString- The content, that shall be written.- Throws:
IOException
-
writeCOSFloat
Write the givenCOSFloatto the given stream.- Parameters:
output- The stream, that shall be written to.cosFloat- The content, that shall be written.- Throws:
IOException
-
writeCOSInteger
Write the givenCOSIntegerto the given stream.- Parameters:
output- The stream, that shall be written to.cosInteger- The content, that shall be written.- Throws:
IOException
-
writeCOSBoolean
Write the givenCOSBooleanto the given stream.- Parameters:
output- The stream, that shall be written to.cosBoolean- The content, that shall be written.- Throws:
IOException
-
writeCOSName
Write the givenCOSNameto the given stream.- Parameters:
output- The stream, that shall be written to.cosName- The content, that shall be written.- Throws:
IOException
-
writeCOSArray
Write the givenCOSArrayto 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 givenCOSDictionaryto 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 givenCOSObjectKeyto the given stream.- Parameters:
output- The stream, that shall be written to.indirectReference- The content, that shall be written.- Throws:
IOException
-
writeCOSNull
WriteCOSNullto the given stream.- Parameters:
output- The stream, that shall be written to.- Throws:
IOException
-