Class PdfXObjectDuplicationOptimizer

java.lang.Object
com.itextpdf.pdfoptimizer.AbstractOptimizationHandler
com.itextpdf.pdfoptimizer.handlers.PdfXObjectDuplicationOptimizer

public class PdfXObjectDuplicationOptimizer extends AbstractOptimizationHandler
Looks for equal streams and performs optimization by replacing them with a reference to a single stream.
  • 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 if PdfDocument.isFlushUnusedObjects() returns false then they will be ignored during flushing.
      Specified by:
      optimizePdf in class AbstractOptimizationHandler
      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