Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

added return end_obj method from process page so that we can iterate … #235

Open
wants to merge 1 commit into
base: master
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
3 changes: 1 addition & 2 deletions pdfminer/pdfinterp.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,8 +837,7 @@ def process_page(self, page):
ctm = (1, 0, 0, 1, -x0, -y0)
self.device.begin_page(page, ctm)
self.render_contents(page.resources, page.contents, ctm=ctm)
self.device.end_page(page)
return
return self.device.end_page(page)

# render_contents(resources, streams, ctm)
# Render the content streams.
Expand Down
9 changes: 9 additions & 0 deletions pdfminer/pdfparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def set_document(self, doc):

KEYWORD_R = KWD(b'R')
KEYWORD_NULL = KWD(b'null')
KEYWORD_OBJ = KWD(b'obj')
KEYWORD_ENDOBJ = KWD(b'endobj')
KEYWORD_STREAM = KWD(b'stream')
KEYWORD_XREF = KWD(b'xref')
Expand All @@ -63,6 +64,14 @@ def do_keyword(self, pos, token):
if token in (self.KEYWORD_XREF, self.KEYWORD_STARTXREF):
self.add_results(*self.pop(1))

elif token is self.KEYWORD_OBJ:
# Handle implicit endobj in some bugged PDFs
if len(self.curstack) > 2:
stack = self.popall()
self.add_results(*stack[0:-2])
self.push(*stack[-2:])
self.push((pos, token))

elif token is self.KEYWORD_ENDOBJ:
self.add_results(*self.pop(4))

Expand Down