Package com.itextpdf.kernel.pdf
Class RunLengthCompressionStrategy
java.lang.Object
com.itextpdf.kernel.pdf.RunLengthCompressionStrategy
- All Implemented Interfaces:
-
IStreamCompressionStrategy
A compression strategy that uses the
RunLengthDecode filter for PDF streams.
This strategy implements the IStreamCompressionStrategy interface and provides RunLengthDecode encoding.
Run-length encoding works best, when input data has long sequences of identical bytes. This is, usually, not the case for PDF content streams, so using this strategy will often cause a marginal size increase instead.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateNewOutputStream(OutputStream original, PdfStream stream) Creates a new output stream with run length compression applied.Returns the decode parameters for theRunLengthDecodefilter.Returns the name of the compression filter.
-
Constructor Details
-
RunLengthCompressionStrategy
public RunLengthCompressionStrategy()Constructs a newRunLengthCompressionStrategyinstance.
-
-
Method Details
-
getFilterName
Returns the name of the compression filter.- Specified by:
-
getFilterNamein interfaceIStreamCompressionStrategy - Returns:
-
PdfName.RunLengthDecoderepresenting theRunLengthDecodefilter
-
getDecodeParams
Returns the decode parameters for theRunLengthDecodefilter.This implementation returns
nullas no special decode parameters are required for standard run length compression.- Specified by:
-
getDecodeParamsin interfaceIStreamCompressionStrategy - Returns:
-
nullas no decode parameters are needed
-
createNewOutputStream
Creates a new output stream with run length compression applied.This method wraps the original output stream in a
RunLengthOutputStreamthat applies run length compression.- Specified by:
-
createNewOutputStreamin interfaceIStreamCompressionStrategy - Parameters:
-
original- the original output stream to wrap -
stream- the PDF stream containing compression configuration - Returns:
-
a new
RunLengthOutputStreamthat compresses data using the run length algorithm
-