Advertisement
Guest User

Uncompress all streams from a PDF file

a guest
Oct 4th, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  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 = ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement