Class ImageQualityOptimizer
java.lang.Object
com.itextpdf.pdfoptimizer.AbstractOptimizationHandler
com.itextpdf.pdfoptimizer.handlers.ImageQualityOptimizer
Looks for image streams and performs theirs optimization.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates 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 voidoptimizePdf(com.itextpdf.kernel.pdf.PdfDocument document, OptimizationSession session) The method searches across all the document and for each foundPdfImageXObjectperforms an optimization according to its type.setJBig2Processor(IImageProcessor processor) Sets a processor forImageType.JBIG2images.setJpeg2000Processor(IImageProcessor processor) Sets a processor forImageType.JPEG2000images.setJpegProcessor(IImageProcessor processor) Sets a processor forImageType.JPEGimages.setPngProcessor(IImageProcessor processor) Sets a processor forImageType.PNGimages.setPredicate(PdfImageXObjectPredicate predicate) Sets a search predicate.setTiffProcessor(IImageProcessor processor) Sets a processor forImageType.TIFFimages.
-
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.JPEGimages. 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.JPEG2000images. 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.JBIG2images. 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.TIFFimages. 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.PNGimages. 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 ofPdfImageXObjectPredicatewith 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
ImageTypekeys 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 foundPdfImageXObjectperforms an optimization according to its type.- Specified by:
-
optimizePdfin 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
-