Remove PDF textcontents without annotations. #3145
Unanswered
pachhaipurna
asked this question in
Looking for help
Replies: 2 comments 2 replies
-
You are trying to do this with redactions, I suppose? |
Beta Was this translation helpful? Give feedback.
2 replies
-
You could try this hack. Please use it without warranty. import fitz
doc = fitz.open("input.pdf")
page = doc[0]
# get annotation array
aarray = doc.xref_get_key(page.xref, "Annots")
# set annotation to empty
doc.xref_set_key(page.xref, "Annots", "[]")
# clear all page content
page.add_redact_annot(page.rect)
page.apply_redactions()
# restore old annotation array
doc.xref_set_key(page.xref, "Annots", aarray[1])
# put content of page 'pno' of 'src' PDF onto this page
page.show_pdf_page(page.rect, src, pno)
doc.ez_save("output.pdf") |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is it possible to remove pdf text contents without removing annotations, I am trying to replace pdf page from another pdf.
Currently when I replace pdf page the pdf size is increasing so, I want to clean up the page content at first and then replace with another pdf page. I think this will helps not to increase pdf size.
Currently I am hiding page content with white color and replacing pdf page.
Anyone with this experience, Please help me,
@JorjMcKie Could you please help me ?
Thank you
Beta Was this translation helpful? Give feedback.
All reactions