A Python utility to clone all metadata (Info dictionary, XMP, dates, and Producer) from one PDF file to another.
- Exact Metadata Cloning: Copies
/Title,/Author,/Subject,/Keywords, dates, and more. - XMP Support: Mirrors XMP metadata hierarchy.
- Strict Mirroring: strips all existing metadata from the target file relative to the source (prevents "ghost" tags).
- Producer Spoofing: Forcefully copies the
Producer(Encoding Software) field, preventing libraries likepikepdffrom adding their own signatures. - Safe Output: Saves the result as
[Source Name] (edit).pdfto avoid overwriting files.
-
Create a virtual environment (optional but recommended):
python3 -m venv .venv source .venv/bin/activate -
Install dependencies:
pip install -r requirements.txt
python clonemeta.py <source_pdf> <target_pdf>python clonemeta.py "reference_doc.pdf" "my_new_doc.pdf"This will create reference_doc (edit).pdf containing the content of my_new_doc.pdf looking exactly like reference_doc.pdf in terms of metadata properties.
To run the comprehensive test suite:
python -m unittest discover tests- Strips the target PDF of all existing
/Infoand XMP metadata. - Copies the full
/Infodictionary from source to target. - Copies the XMP packet (if present in source).
- Resets the
/Producerfield to match the source exactly, bypassing standard library behavior that tries to watermark the file.