Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- ........
- %xref
- %0 8
- %0000000000 65535 f
- %0000000010 00000 n
- %0000000079 00000 n
- %0000000179 00000 n
- %0000000315 00000 n
- %0000000394 00000 n
- %0000000506 00000 n
- %0000000602 00000 n
- trailer
- <<
- /Size 8
- /Root 1 0 R
- >>
- %startxref
- %732
- %%EOF
- """
- #We want to get '732' value
- def getXrefTable(hfile):
- hfile.seek(0, 2)
- size = hfile.tell()
- chunk=100 #1 iteration is enough in most cases i hope
- for i in range(1, int(size/chunk)+1):
- hfile.seek(-chunk*i, 2)
- dat = filter(bool, [l.strip() for l in hfile.readlines()])
- if len(dat) > 3: #to be sure that we've read last 3 lines
- if (dat[-1]=="%%EOF") & (dat[-3]=="startxref"):
- xrefpos=int(dat[-2])
- break
- return xrefpos
Advertisement
Add Comment
Please, Sign In to add comment