Package org.apache.pdfbox.multipdf
Class PDFCloneUtility
- java.lang.Object
-
- org.apache.pdfbox.multipdf.PDFCloneUtility
-
public class PDFCloneUtility extends java.lang.ObjectUtility class used to clone PDF objects. It keeps track of objects it has already cloned.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<COSBase>clonedValuesprivate java.util.Map<COSBase,COSBase>clonedVersionprivate PDDocumentdestinationprivate static org.apache.commons.logging.LogLOG
-
Constructor Summary
Constructors Modifier Constructor Description protectedPDFCloneUtility(PDDocument dest)Creates a new instance for the given target document.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private COSArraycloneCOSArray(COSArray array)private COSBasecloneCOSBaseForNewDocument(COSBase base)private COSDictionarycloneCOSDictionary(COSDictionary dictionary)private COSStreamcloneCOSStream(COSStream stream)<TCOSBase extends COSBase>
TCOSBasecloneForNewDocument(TCOSBase base)Deep-clones the given object for inclusion into a different PDF document identified by the destination parameter.(package private) voidcloneMerge(COSObjectable base, COSObjectable target)Merges two objects of the same type by deep-cloning its members.private voidcloneMergeCOSBase(COSBase source, COSBase target)(package private) PDDocumentgetDestination()Returns the destination PDF document this cloner instance is set up for.private booleanhasSelfReference(COSBase parent, COSBase value)Check whether an element (of an array or a dictionary) points to its parent.
-
-
-
Field Detail
-
LOG
private static final org.apache.commons.logging.Log LOG
-
destination
private final PDDocument destination
-
clonedValues
private final java.util.Set<COSBase> clonedValues
-
-
Constructor Detail
-
PDFCloneUtility
protected PDFCloneUtility(PDDocument dest)
Creates a new instance for the given target document.- Parameters:
dest- the destination PDF document that will receive the clones
-
-
Method Detail
-
getDestination
PDDocument getDestination()
Returns the destination PDF document this cloner instance is set up for.- Returns:
- the destination PDF document
-
cloneForNewDocument
public <TCOSBase extends COSBase> TCOSBase cloneForNewDocument(TCOSBase base) throws java.io.IOException
Deep-clones the given object for inclusion into a different PDF document identified by the destination parameter. Expert use only, don’t use it if you don’t know exactly what you are doing.- Type Parameters:
TCOSBase- The type to be returned.- Parameters:
base- the initial object as the root of the deep-clone operation- Returns:
- the cloned instance of the base object
- Throws:
java.io.IOException- if an I/O error occurs
-
cloneCOSBaseForNewDocument
private COSBase cloneCOSBaseForNewDocument(COSBase base) throws java.io.IOException
- Throws:
java.io.IOException
-
cloneCOSArray
private COSArray cloneCOSArray(COSArray array) throws java.io.IOException
- Throws:
java.io.IOException
-
cloneCOSStream
private COSStream cloneCOSStream(COSStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
cloneCOSDictionary
private COSDictionary cloneCOSDictionary(COSDictionary dictionary) throws java.io.IOException
- Throws:
java.io.IOException
-
cloneMerge
void cloneMerge(COSObjectable base, COSObjectable target) throws java.io.IOException
Merges two objects of the same type by deep-cloning its members.
Base and target must be instances of the same class.- Parameters:
base- the base object to be clonedtarget- the merge target- Throws:
java.io.IOException- if an I/O error occurs
-
cloneMergeCOSBase
private void cloneMergeCOSBase(COSBase source, COSBase target) throws java.io.IOException
- Throws:
java.io.IOException
-
-