Class ReplaceObjectsAction

java.lang.Object
com.itextpdf.pdfoptimizer.util.traversing.ReplaceObjectsAction
All Implemented Interfaces:
IAction

public class ReplaceObjectsAction extends Object implements IAction
Replace objects in document structure according to provided rule.
  • Constructor Details

    • ReplaceObjectsAction

      public ReplaceObjectsAction (Mapcom.itextpdf.kernel.pdf.PdfObject> schema)
      Performs objects replacement according to a provided schema. There are several limitations:
      • PdfObject to be replaced is identified by Object.equals(Object) method. Depending on the class implementation it might comparing by content or by reference.
      • no transitivity is allowed. An object cannot replace the second object and be replaced by the third one.
      Parameters:
      schema - is a schema of replacement. It is a map where a key stands for the object to be replaced and the value stands for the object to replace.
  • Method Details

    • processIndirectObjectDefinition

      public void processIndirectObjectDefinition (com.itextpdf.kernel.pdf.PdfObject object)
      Does nothing as indirect object cannot be replaced. If it has to be removed, it will be ignored on flushing as unused indirect object (supposing that PdfDocument.isFlushUnusedObjects() is set to false).
      Specified by:
      processIndirectObjectDefinition in interface IAction
      Parameters:
      object - is an indirect object definition to process
    • processObject

      public com.itextpdf.kernel.pdf.PdfObject processObject (com.itextpdf.kernel.pdf.PdfObject object)
      Replaces object if necessary according to the provided schema.
      Specified by:
      processObject in interface IAction
      Parameters:
      object - is a current PdfObject
      Returns:
      an object that should replace current one. Can be the same instance as argument to avoid replacement