pypdf
pypdf copied to clipboard
Clone Objects
Explanation
I've noted some (many?) issues dealing that PyPDF2 is missing capability to clone objects (and all items below) for example this would allow to insert the same page multiple time but modifying it
Code Example
the proposed interface would be (for all type of objects)
object.clone(pdf_dest,force_duplicate=False) -> duplicated_object
pdf_dest would be a PdfWriter or PdfMerger
by default already duplicated indirect object will be kept unique but setting force_duplicate to true will force duplication
Any Feedbacks?
Sounds good!
I couldn't pin-point specific issues that were caused by this missing feature, but I also have the impression it would be helpful in some cases.
I'm uncertain what a good interface would be. Would the proposed interface mean we could take an object from a PdfReader and clone it to a PdfWriter? What would happen to (indirect) objects referenced within the cloned object? Do we maybe need a deep
parameter (where False
would mean a shallow copy of only the cloned object, and deep would mean a recursive approach)?
cloning has been introduced.