Class ReplaceObjectsAction
java.lang.Object
com.itextpdf.pdfoptimizer.util.traversing.ReplaceObjectsAction
- All Implemented Interfaces:
-
IAction
Replace objects in document structure according to provided rule.
-
Constructor Summary
ConstructorDescriptionReplaceObjectsAction
(Map com.itextpdf.kernel.pdf.PdfObject> schema) Performs objects replacement according to a provided schema. -
Method Summary
Modifier and TypeMethodDescriptionvoid
processIndirectObjectDefinition
(com.itextpdf.kernel.pdf.PdfObject object) Does nothing as indirect object cannot be replaced.com.itextpdf.kernel.pdf.PdfObject
processObject
(com.itextpdf.kernel.pdf.PdfObject object) Replaces object if necessary according to the provided schema.
-
Constructor Details
-
ReplaceObjectsAction
Performs objects replacement according to a provided schema. There are several limitations:PdfObject
to be replaced is identified byObject.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 thatPdfDocument.isFlushUnusedObjects()
is set to false).- Specified by:
-
processIndirectObjectDefinition
in interfaceIAction
- 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 interfaceIAction
- Parameters:
-
object
- is a currentPdfObject
- Returns:
- an object that should replace current one. Can be the same instance as argument to avoid replacement
-