View Single Post
Old 06-23-2023, 10:37 AM   #18
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
To remove header + footer on all the pages:

Code:
doc = fitz.open("input.pdf")
#To find mediabox of page 25 in input file: cpdf -page-info input.pdf 25

WIDTH = doc[0].mediabox.width
HEIGHT = doc[0].mediabox.height
rect_header = fitz.Rect(0,0,WIDTH,50) #left,top, right,bottom
rect_footer = fitz.Rect(0,770,WIDTH,790)

numpages = doc.page_count
for index in range(numpages):
	page = doc[index]
	page.add_redact_annot(rect_header)
	page.add_redact_annot(rect_footer)
	page.apply_redactions()
doc.save("redacted.pdf")

#ebook-convert.exe redacted.pdf redacted.epub

Last edited by Shohreh; 06-23-2023 at 04:29 PM.
Shohreh is offline   Reply With Quote