Skip to content
This repository was archived by the owner on Apr 11, 2025. It is now read-only.

Commit 706ea1a

Browse files
authored
Merge pull request #5 from karlowich/optimise-get_page_layout
[MRG] Utils: optimise get_page_layout
2 parents b68c489 + db01b68 commit 706ea1a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

camelot/utils.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -888,12 +888,14 @@ def get_page_layout(
888888
rsrcmgr = PDFResourceManager()
889889
device = PDFPageAggregator(rsrcmgr, laparams=laparams)
890890
interpreter = PDFPageInterpreter(rsrcmgr, device)
891-
for page in PDFPage.create_pages(document):
892-
interpreter.process_page(page)
893-
layout = device.get_result()
894-
width = layout.bbox[2]
895-
height = layout.bbox[3]
896-
dim = (width, height)
891+
page = next(PDFPage.create_pages(document), None)
892+
if page is None:
893+
raise PDFTextExtractionNotAllowed
894+
interpreter.process_page(page)
895+
layout = device.get_result()
896+
width = layout.bbox[2]
897+
height = layout.bbox[3]
898+
dim = (width, height)
897899
return layout, dim
898900

899901

0 commit comments

Comments
 (0)