-
ExplanationI'd like to replace the contents of a page with multiple images for one with a single background image (preserving the page text), however since the image list is read only this is not possible Code Examplefrom pypdf import PdfReader, PdfWriter
input_pdf = PdfReader(path)
output_pdf = PdfWriter(clone_from=input_pdf)
page = output_pdf.pages[0]
page.images.clear()
page.images.append(bg_image) AlternativeAn option to clone a page leaving the images out |
Beta Was this translation helpful? Give feedback.
Answered by
pubpub-zz
Jul 8, 2024
Replies: 1 comment
-
you have 2 options:
b) you delete all images, then create new pdf using pillow , and merge pages placing the new one behind
PS: I convert this as a discussion as this not an issue |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
stefan6419846
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you have 2 options:
a) you know which image is the one to replace:
eg:
b) you delete all images, then create new pdf using pillow , and merge pages placing the new one behind
PS: I convert this as a discussion as this not an issue