Skip to content

Instantly share code, notes, and snippets.

@yohann84L
Created February 4, 2020 09:04
Show Gist options
  • Save yohann84L/f07f5b2accca140b81cd6c4d8a700653 to your computer and use it in GitHub Desktop.
Save yohann84L/f07f5b2accca140b81cd6c4d8a700653 to your computer and use it in GitHub Desktop.
Remove text from PDF
def get_pdf_without_text(pdf: fitz.Document) -> fitz.Document:
for i in range(0, pdf.pageCount):
page = pdf[i]
for xref in page._getContents():
stream = pdf._getXrefStream(xref).replace(b'Tm', b'Tm\n3 Tr')
pdf._updateStream(xref, stream)
return pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment