diff --git a/pdfminer/pdfparser.py b/pdfminer/pdfparser.py index 645e0dec..dae1af59 100644 --- a/pdfminer/pdfparser.py +++ b/pdfminer/pdfparser.py @@ -146,7 +146,12 @@ def flush(self) -> None: def do_keyword(self, pos: int, token: PSKeyword) -> None: if token is self.KEYWORD_R: # reference to indirect object - (_, _object_id), _ = self.pop(2) + try: + (_, _object_id), _ = self.pop(2) + except ValueError: + raise PDFSyntaxError( + "Expected generation and object id in indirect object reference" + ) object_id = safe_int(_object_id) if object_id is not None: obj = PDFObjRef(self.doc, object_id) diff --git a/pdfminer/utils.py b/pdfminer/utils.py index 88b44b98..277cfe15 100644 --- a/pdfminer/utils.py +++ b/pdfminer/utils.py @@ -245,7 +245,7 @@ def parse_rect(o: Any) -> Rect: try: (x0, y0, x1, y1) = o return float(x0), float(y0), float(x1), float(y1) - except ValueError: + except (ValueError, TypeError): raise PDFValueError("Could not parse rectangle")