Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TypeError that leads to an unhandled Exception #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Jose Miguel Esparza <jesparza AT eternal-todo.com>
http://eternal-todo.com
http://twitter.com/EternalTodo
http://twitter.com/EternalTodo

Sebastian Deiss <sebastian DOT deiss AT atos DOT net>
https://pages.atos.net/de/sc/
https://github.com/SebastianDeiss
9 changes: 5 additions & 4 deletions peepdf/PDFCore.py
Original file line number Diff line number Diff line change
Expand Up @@ -2685,7 +2685,8 @@ def setRawStream(self, newStream):


class PDFObjectStream (PDFStream):
def __init__(self, rawDict='', rawStream='', elements={}, rawNames={}, compressedObjectsDict={}):
def __init__(self, rawDict='', rawStream='', elements={}, rawNames={}, compressedObjectsDict={}, parser=None):
self.parser = parser
self.type = 'stream'
self.dictType = ''
self.errors = []
Expand Down Expand Up @@ -3247,8 +3248,8 @@ def resolveReferences(self):
numbers = re.findall('\d{1,10}', offsetsSection)
if numbers != [] and len(numbers) % 2 == 0:
for i in range(0, len(numbers), 2):
offset = numbers[i+1]
ret = PDFParser.readObject(objectsSection[offset:])
offset = int(numbers[i + 1])
ret = self.parser.readObject(objectsSection[offset:])
if ret[0] == -1:
if isForceMode:
object = None
Expand Down Expand Up @@ -7417,7 +7418,7 @@ def createPDFStream(self, dict, stream):
name = ret[1]
if "/Type" in elements and elements['/Type'].getValue() == '/ObjStm':
try:
pdfStream = PDFObjectStream(dict, stream, elements, rawNames, {})
pdfStream = PDFObjectStream(dict, stream, elements, rawNames, {}, parser=self)
except Exception as e:
errorMessage = 'Error creating PDFObjectStream'
if e.message != '':
Expand Down