Class PdfXObjectDuplicationOptimizer
java.lang.Object
com.itextpdf.pdfoptimizer.AbstractOptimizationHandler
com.itextpdf.pdfoptimizer.handlers.PdfXObjectDuplicationOptimizer
Looks for equal streams and performs optimization by replacing them with a reference to a single stream.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty xObject duplication optimizer. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
optimizePdf
(com.itextpdf.kernel.pdf.PdfDocument document, OptimizationSession session) The method searches for streams in PdfDocument and compares them.
-
Constructor Details
-
PdfXObjectDuplicationOptimizer
public PdfXObjectDuplicationOptimizer()Creates an empty xObject duplication optimizer.
-
-
Method Details
-
optimizePdf
protected void optimizePdf(com.itextpdf.kernel.pdf.PdfDocument document, OptimizationSession session) The method searches for streams in PdfDocument and compares them. If two streams are same (dictionaries and stream bytes) and can be merged into one then optimizer does it and replace all old pdf streams with indirect reference. Duplicated direct objects will be removed. Definitions of indirect objects will be left, however ifPdfDocument.isFlushUnusedObjects()
returnsfalse
then they will be ignored during flushing.- 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
-