SHARE
TWEET

Uncompress all streams from a PDF file

a guest Oct 4th, 2014 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import sys
  2. import zlib
  3.  
  4. fn = sys.argv[1]
  5. fd = open(sys.argv[1], "r")
  6. fbin = fd.read()
  7.  
  8. while len(fbin) > 0:
  9.         foffss = str.find(fbin, "stream")
  10.         foffse = str.find(fbin, "endstream")
  11.         #print "From " + str(foffss) + " to " + str(foffse) + "\n"
  12.        
  13.         if ((foffss >= 0) and (foffse >= 0)):
  14.                 fslice = fbin[(foffss + 7) : foffse]
  15.                
  16.                 try:
  17.                         ftxt = zlib.decompress(fslice)
  18.                 except:
  19.                         ftxt = ""
  20.                
  21.                 print ftxt
  22.                 fbin = fbin[(foffse + 10) : ]
  23.         else:
  24.                 fbin = ""
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top