View Single Post
Old 05-14-2023, 08:48 AM   #10
Shohreh
Addict
Shohreh ought to be getting tired of karma fortunes by now.Shohreh ought to be getting tired of karma fortunes by now.Shohreh ought to be getting tired of karma fortunes by now.Shohreh ought to be getting tired of karma fortunes by now.Shohreh ought to be getting tired of karma fortunes by now.Shohreh ought to be getting tired of karma fortunes by now.Shohreh ought to be getting tired of karma fortunes by now.Shohreh ought to be getting tired of karma fortunes by now.Shohreh ought to be getting tired of karma fortunes by now.Shohreh ought to be getting tired of karma fortunes by now.Shohreh ought to be getting tired of karma fortunes by now.
 
Posts: 207
Karma: 304158
Join Date: Jan 2016
Location: France
Device: none
PyMuPDF to the rescue…

Code:
#https://artifex.com/blog/advanced-text-manipulation-using-pymupdf
import fitz

doc = fitz.open("original.pdf")
page = doc[18]

#print(page.get_text())
rect = fitz.Rect(0,0,424,50)
page.add_redact_annot(rect)
page.apply_redactions()

doc.save("redacted.pdf")

#ebook-convert.exe redacted.pdf redacted.epub
Hard to believe no ready-to-use command-line tool can add and delete redaction annotations.

Another useful tool would be a PDF viewer that lets the user select a rectangle and display its coordinates, ready to be copy-pasted into the command line.
Attached Thumbnails
Click image for larger version

Name:	0A672E69-5381-4EAD-81D4-AA3CCE0654D2.png
Views:	514
Size:	101.2 KB
ID:	201543  

Last edited by Shohreh; 05-14-2023 at 09:11 AM.
Shohreh is offline   Reply With Quote