Class ImageQualityOptimizer
java.lang.Object
com.itextpdf.pdfoptimizer.AbstractOptimizationHandler
com.itextpdf.pdfoptimizer.handlers.ImageQualityOptimizer
Looks for image streams and performs theirs optimization.
-
Constructor Summary
ConstructorDescriptionCreates an empty image quality optimizer.ImageQualityOptimizer
(Map IImageProcessor> processors) Creates a new image quality optimizer with custom configuration of image processors. -
Method Summary
Modifier and TypeMethodDescriptionGets a copy of current configuration of the image processor.Gets current search predicate.protected void
optimizePdf
(com.itextpdf.kernel.pdf.PdfDocument document, OptimizationSession session) The method searches across all the document and for each foundPdfImageXObject
performs an optimization according to its type.setJBig2Processor
(IImageProcessor processor) Sets a processor forImageType.JBIG2
images.setJpeg2000Processor
(IImageProcessor processor) Sets a processor forImageType.JPEG2000
images.setJpegProcessor
(IImageProcessor processor) Sets a processor forImageType.JPEG
images.setPngProcessor
(IImageProcessor processor) Sets a processor forImageType.PNG
images.setPredicate
(PdfImageXObjectPredicate predicate) Sets a search predicate.setTiffProcessor
(IImageProcessor processor) Sets a processor forImageType.TIFF
images.
-
Constructor Details
-
ImageQualityOptimizer
public ImageQualityOptimizer()Creates an empty image quality optimizer. -
ImageQualityOptimizer
Creates a new image quality optimizer with custom configuration of image processors. Note that type of the image is identifying based onPdfImageXObject.identifyImageType()
call.- Parameters:
-
processors
- is a map where image types are associated with processors for them - See Also:
-
PdfImageXObject.identifyImageType()
-
-
Method Details
-
setJpegProcessor
Sets a processor forImageType.JPEG
images. Note that type of the image is identifying based onPdfImageXObject.identifyImageType()
call.- Parameters:
-
processor
- is an image processor to set - Returns:
- this instance
- See Also:
-
PdfImageXObject.identifyImageType()
-
setJpeg2000Processor
Sets a processor forImageType.JPEG2000
images. Note that type of the image is identifying based onPdfImageXObject.identifyImageType()
call.- Parameters:
-
processor
- is an image processor to set - Returns:
- this instance
- See Also:
-
PdfImageXObject.identifyImageType()
-
setJBig2Processor
Sets a processor forImageType.JBIG2
images. Note that type of the image is identifying based onPdfImageXObject.identifyImageType()
call.- Parameters:
-
processor
- is an image processor to set - Returns:
- this instance
- See Also:
-
PdfImageXObject.identifyImageType()
-
setTiffProcessor
Sets a processor forImageType.TIFF
images. Note that type of the image is identifying based onPdfImageXObject.identifyImageType()
call.- Parameters:
-
processor
- is an image processor to set - Returns:
- this instance
- See Also:
-
PdfImageXObject.identifyImageType()
-
setPngProcessor
Sets a processor forImageType.PNG
images. Note that type of the image is identifying based onPdfImageXObject.identifyImageType()
call.- Parameters:
-
processor
- is an image processor to set - Returns:
- this instance
- See Also:
-
PdfImageXObject.identifyImageType()
-
setPredicate
Sets a search predicate. Allows to provide custom implementation ofPdfImageXObjectPredicate
with overridden methodPdfImageXObjectPredicate.customCondition(PdfObject)
to skip some types of images during optimization process.- Parameters:
-
predicate
- is a predicate to set - Returns:
- this instance
-
getPredicate
Gets current search predicate. If it was not set return default implementation.- Returns:
- search predicate.
-
getImageProcessors
Gets a copy of current configuration of the image processor.- Returns:
-
a map where
ImageType
keys are associated with actualIImageProcessor
-
optimizePdf
protected void optimizePdf(com.itextpdf.kernel.pdf.PdfDocument document, OptimizationSession session) The method searches across all the document and for each foundPdfImageXObject
performs an optimization according to its type.- Specified by:
-
optimizePdf
in classAbstractOptimizationHandler
- Parameters:
-
document
- is the PDF document to optimize. Invocation of the method can change the state of the object -
session
- is an auxiliary object used to support share data between stages of optimization process
-