Version 1.11.0 of PyMuPDF allows putting an image on an existing PDF page. The following example puts the same image on every page of a given PDF - like a thumbnail.
1 2 3 4 5 6 7 8
import fitz # <-- PyMuPDF doc = fitz.open("some.pdf") # open the PDF rect = fitz.Rect(0, 0, 100, 100) # where to put image: use upper left corner for page in doc: page.insertImage(rect, filename = "some.image") doc.saveIncr() # do an incremental save
The above script is very fast: to stamp every page of Adobe's Reference Manual (1.310 pages) like this should take below 10 seconds. This is because our underlying library MuPDF will insert the new image at most one time. Existing images are being checked whether they contain the same picture - if so, only a reference to it will be inserted.