Skip to content

Instantly share code, notes, and snippets.

@suidroot
Created December 29, 2020 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suidroot/861668f1bb9669f1cae61d0a9f8d8a9e to your computer and use it in GitHub Desktop.
Save suidroot/861668f1bb9669f1cae61d0a9f8d8a9e to your computer and use it in GitHub Desktop.
PDF Deflate Extractor
import re
import zlib
pdf = open("Receipt.pdf", "rb").read()
stream = re.compile(b'.*?FlateDecode.*?stream(.*?)endstream', re.S)
counter = 0
for s in re.findall(stream,pdf):
print("---------------------- " + str(counter) + "---------- ")
s = s.strip(b'\r\n')
try:
print(zlib.decompress(s).decode('UTF-8'))
print("")
except:
pass
counter +=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment