mirror of
https://github.com/apprenticeharper/DeDRM_tools
synced 2024-12-28 09:58:56 +01:00
ineptpdf 7.3
This commit is contained in:
parent
b92458c8c2
commit
ab9d585190
1 changed files with 16 additions and 14 deletions
30
ineptpdf.pyw
30
ineptpdf.pyw
|
@ -1,7 +1,7 @@
|
||||||
#! /usr/bin/python
|
#! /usr/bin/python
|
||||||
|
|
||||||
# ineptpdf72.pyw
|
# ineptpdf73.pyw
|
||||||
# ineptpdf, version 7.2
|
# ineptpdf, version 7.3
|
||||||
|
|
||||||
# To run this program install Python 2.6 from http://www.python.org/download/
|
# To run this program install Python 2.6 from http://www.python.org/download/
|
||||||
# and PyCrypto from http://www.voidspace.org.uk/python/modules.shtml#pycrypto
|
# and PyCrypto from http://www.voidspace.org.uk/python/modules.shtml#pycrypto
|
||||||
|
@ -22,7 +22,9 @@
|
||||||
# 7.1 - Correct a problem when an old trailer is not followed by startxref
|
# 7.1 - Correct a problem when an old trailer is not followed by startxref
|
||||||
# 7.2 - Correct malformed Mac OS resource forks for Stanza
|
# 7.2 - Correct malformed Mac OS resource forks for Stanza
|
||||||
# - Support for cross ref streams on output (decreases file size)
|
# - Support for cross ref streams on output (decreases file size)
|
||||||
#
|
# 7.3 - Correct bug in trailer with cross ref stream that caused the error
|
||||||
|
# "The root object is missing or invalid" in Adobe Reader.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Decrypt Adobe ADEPT-encrypted PDF files.
|
Decrypt Adobe ADEPT-encrypted PDF files.
|
||||||
"""
|
"""
|
||||||
|
@ -1663,6 +1665,10 @@ class PDFSerializer(object):
|
||||||
first = None
|
first = None
|
||||||
prev = None
|
prev = None
|
||||||
data = []
|
data = []
|
||||||
|
# Put the xrefstream's reference in itself
|
||||||
|
startxref = self.tell()
|
||||||
|
maxobj += 1
|
||||||
|
xrefs[maxobj] = (startxref, 0)
|
||||||
for objid in sorted(xrefs):
|
for objid in sorted(xrefs):
|
||||||
if first is None:
|
if first is None:
|
||||||
first = objid
|
first = objid
|
||||||
|
@ -1687,17 +1693,13 @@ class PDFSerializer(object):
|
||||||
data = zlib.compress(''.join(data))
|
data = zlib.compress(''.join(data))
|
||||||
dic = {'Type': LITERAL_XREF, 'Size': prev + 1, 'Index': index,
|
dic = {'Type': LITERAL_XREF, 'Size': prev + 1, 'Index': index,
|
||||||
'W': [1, fl2, fl3], 'Length': len(data),
|
'W': [1, fl2, fl3], 'Length': len(data),
|
||||||
'Filter': LITERALS_FLATE_DECODE[0],}
|
'Filter': LITERALS_FLATE_DECODE[0],
|
||||||
obj = PDFStream(dic, data)
|
'Root': trailer['Root'],}
|
||||||
trailer['XRefStm'] = startxrefstm = self.tell()
|
if 'Info' in trailer:
|
||||||
self.serialize_indirect(maxobj + 1, 0, obj)
|
dic['Info'] = trailer['Info']
|
||||||
startxref = self.tell()
|
xrefstm = PDFStream(dic, data)
|
||||||
self.write('xref\n')
|
self.serialize_indirect(maxobj, 0, xrefstm)
|
||||||
self.write('%d 1\n' % (maxobj + 1,))
|
self.write('startxref\n%d\n%%%%EOF' % startxref)
|
||||||
self.write("%010d %05d n \n" % (startxrefstm, 0))
|
|
||||||
self.write('trailer\n')
|
|
||||||
self.serialize_object(trailer)
|
|
||||||
self.write('\nstartxref\n%d\n%%%%EOF' % startxref)
|
|
||||||
|
|
||||||
def write(self, data):
|
def write(self, data):
|
||||||
self.outf.write(data)
|
self.outf.write(data)
|
||||||
|
|
Loading…
Reference in a new issue