Top Description Fields Constructors Methods
org.apache.pdfbox.filter

public abstract Class Filter

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.pdfbox.filter.FlateFilter, org.apache.pdfbox.filter.IdentityFilter, org.apache.pdfbox.filter.JBIG2Filter, org.apache.pdfbox.filter.JPXFilter, org.apache.pdfbox.filter.LZWFilter, org.apache.pdfbox.filter.RunLengthDecodeFilter, org.apache.pdfbox.filter.ASCII85Filter, org.apache.pdfbox.filter.ASCIIHexFilter, org.apache.pdfbox.filter.CCITTFaxFilter, org.apache.pdfbox.filter.CryptFilter, org.apache.pdfbox.filter.DCTFilter
Imports
java.io.IOException, .InputStream, .OutputStream, java.util.ArrayList, .HashSet, .Iterator, .List, .Set, java.util.zip.Deflater, javax.imageio.ImageIO, .ImageReader, org.apache.commons.logging.Log, .LogFactory, org.apache.pdfbox.cos.COSArray, .COSBase, .COSDictionary, .COSName, org.apache.pdfbox.io.IOUtils, .RandomAccessInputStream, .RandomAccessOutputStream, .RandomAccessRead, .RandomAccessReadBuffer, .RandomAccessReadWriteBuffer

A filter for stream data.
Authors
Ben Litchfield, John Hewson

Field Summary

Modifier and TypeField and Description
private static final Log
public static final String
SYSPROP_DEFLATELEVEL

Compression Level System Property.

Constructor Summary

AccessConstructor and Description
protected
Filter()

Constructor.

Method Summary

Modifier and TypeMethod and Description
public abstract DecodeResult

Returns:

repaired parameters dictionary, or the original parameters dictionary
decode
(InputStream
the encoded byte stream
encoded
,
OutputStream
the stream where decoded data will be written
decoded
,
COSDictionary
the parameters used for decoding
parameters
,
int
the index to the filter being decoded
index
)

Decodes data, producing the original non-encoded data.

public DecodeResult

Returns:

repaired parameters dictionary, or the original parameters dictionary
decode
(InputStream
the encoded byte stream
encoded
,
OutputStream
the stream where decoded data will be written
decoded
,
COSDictionary
the parameters used for decoding
parameters
,
int
the index to the filter being decoded
index
,
DecodeOptions
additional options for decoding
options
)

Decodes data, with optional DecodeOptions.

public static RandomAccessRead

Returns:

the decoded stream data
decode
(InputStream
the input stream holding the encoded data
encoded
,
List<Filter>
list of filters to be used for decoding
filterList
,
COSDictionary
the parameters used for decoding
parameters
,
DecodeOptions
additional options for decoding
options
,
List<DecodeResult>
list of optional decoding results for each filter
results
)

Decodes data, with optional DecodeOptions.

public final void
encode(InputStream
the byte stream to encode
input
,
OutputStream
the stream where encoded data will be written
encoded
,
COSDictionary
the parameters used for encoding
parameters
,
int
the index to the filter being encoded
index
)

Encodes data.

protected abstract void
encode(InputStream input, OutputStream encoded, COSDictionary parameters)

public static final ImageReader

Returns:

The image reader for the format.
findImageReader
(String
The image format to search for.
formatName
,
String
The probably cause if something goes wrong.
errorCause
)

Finds a suitable image reader for an image format.

public static final ImageReader

Returns:

The image reader for the format.
findRasterReader
(String
The image format to search for.
formatName
,
String
The probably cause if something goes wrong.
errorCause
)

Finds a suitable image raster reader for an image format.

public static int

Returns:

the ZIP compression level configured for PDFBox
getCompressionLevel
()

protected COSDictionary
getDecodeParams(COSDictionary dictionary, int index)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGback to summary
private static final Log LOG
SYSPROP_DEFLATELEVELback to summary
public static final String SYSPROP_DEFLATELEVEL

Compression Level System Property. Set this to a value from 0 to 9 to change the zlib deflate compression level used to compress /Flate streams. The default value is -1 which is Deflater#DEFAULT_COMPRESSION. To set maximum compression, use System.setProperty(Filter.SYSPROP_DEFLATELEVEL, "9");

Constructor Detail

Filterback to summary
protected Filter()

Constructor.

Method Detail

decodeback to summary
public abstract DecodeResult decode(InputStream encoded, OutputStream decoded, COSDictionary parameters, int index) throws IOException

Decodes data, producing the original non-encoded data.

Parameters
encoded:InputStream

the encoded byte stream

decoded:OutputStream

the stream where decoded data will be written

parameters:COSDictionary

the parameters used for decoding

index:int

the index to the filter being decoded

Returns:DecodeResult

repaired parameters dictionary, or the original parameters dictionary

Exceptions
IOException:
if the stream cannot be decoded
decodeback to summary
public DecodeResult decode(InputStream encoded, OutputStream decoded, COSDictionary parameters, int index, DecodeOptions options) throws IOException

Decodes data, with optional DecodeOptions. Not all filters support all options, and so callers should check the options' honored flag to test if they were applied.

Parameters
encoded:InputStream

the encoded byte stream

decoded:OutputStream

the stream where decoded data will be written

parameters:COSDictionary

the parameters used for decoding

index:int

the index to the filter being decoded

options:DecodeOptions

additional options for decoding

Returns:DecodeResult

repaired parameters dictionary, or the original parameters dictionary

Exceptions
IOException:
if the stream cannot be decoded
decodeback to summary
public static RandomAccessRead decode(InputStream encoded, List<Filter> filterList, COSDictionary parameters, DecodeOptions options, List<DecodeResult> results) throws IOException

Decodes data, with optional DecodeOptions. Not all filters support all options, and so callers should check the options' honored flag to test if they were applied.

Parameters
encoded:InputStream

the input stream holding the encoded data

filterList:List<Filter>

list of filters to be used for decoding

parameters:COSDictionary

the parameters used for decoding

options:DecodeOptions

additional options for decoding

results:List<DecodeResult>

list of optional decoding results for each filter

Returns:RandomAccessRead

the decoded stream data

Exceptions
IOException:
if the stream cannot be decoded
IllegalArgumentException:
if filterList is empty
encodeback to summary
public final void encode(InputStream input, OutputStream encoded, COSDictionary parameters, int index) throws IOException

Encodes data.

Parameters
input:InputStream

the byte stream to encode

encoded:OutputStream

the stream where encoded data will be written

parameters:COSDictionary

the parameters used for encoding

index:int

the index to the filter being encoded

Exceptions
IOException:
if the stream cannot be encoded
encodeback to summary
protected abstract void encode(InputStream input, OutputStream encoded, COSDictionary parameters) throws IOException
findImageReaderback to summary
public static final ImageReader findImageReader(String formatName, String errorCause) throws MissingImageReaderException

Finds a suitable image reader for an image format.

Parameters
formatName:String

The image format to search for.

errorCause:String

The probably cause if something goes wrong.

Returns:ImageReader

The image reader for the format.

Exceptions
MissingImageReaderException:
if no image reader is found.
findRasterReaderback to summary
public static final ImageReader findRasterReader(String formatName, String errorCause) throws MissingImageReaderException

Finds a suitable image raster reader for an image format.

Parameters
formatName:String

The image format to search for.

errorCause:String

The probably cause if something goes wrong.

Returns:ImageReader

The image reader for the format.

Exceptions
MissingImageReaderException:
if no image reader is found.
getCompressionLevelback to summary
public static int getCompressionLevel()
Returns:int

the ZIP compression level configured for PDFBox

getDecodeParamsback to summary
protected COSDictionary getDecodeParams(COSDictionary dictionary, int index)