Skip to content

Commit

Permalink
feat: be defensive against missing MediaBox
Browse files Browse the repository at this point in the history
That is invalid PDF, but there are lots of invalid PDFs out there
  • Loading branch information
dhdaines committed Aug 1, 2024
1 parent ad101c1 commit 548c018
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pdfminer/pdfpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ def __init__(
self.resources: Dict[object, object] = resolve1(
self.attrs.get("Resources", dict()),
)
mediabox_params: List[Any] = [
resolve1(mediabox_param)
for mediabox_param in resolve1(self.attrs["MediaBox"])
]
mediabox_params: List[Any] = []
if "MediaBox" in self.attrs:
mediabox_params.extend(
resolve1(mediabox_param)
for mediabox_param in resolve1(self.attrs["MediaBox"])
)
self.mediabox = parse_rect(resolve1(mediabox_params))
self.cropbox = self.mediabox
if "CropBox" in self.attrs:
Expand Down

0 comments on commit 548c018

Please sign in to comment.