From 7d3401fde8a6a52da8c22c21bd3904eea36238b0 Mon Sep 17 00:00:00 2001 From: jeremy-thuon <18218996+jeremythuon@users.noreply.github.com> Date: Mon, 29 Sep 2025 14:57:53 +0200 Subject: [PATCH] Fix unknown type problem loading PDF Signed-off-by: jeremy-thuon <18218996+jeremythuon@users.noreply.github.com> --- docling_parse/pdf_parser.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docling_parse/pdf_parser.py b/docling_parse/pdf_parser.py index db0310df..4e457b3d 100644 --- a/docling_parse/pdf_parser.py +++ b/docling_parse/pdf_parser.py @@ -602,7 +602,10 @@ def load( lazy: bool = True, boundary_type: PdfPageBoundaryType = PdfPageBoundaryType.CROP_BOX, ) -> PdfDocument: - + + success=False + key=None + if isinstance(path_or_stream, str): path_or_stream = Path(path_or_stream) @@ -630,7 +633,10 @@ def load( return result_doc else: - raise RuntimeError(f"Failed to load document with key {key}") + if key: + raise RuntimeError(f"Failed to load document with key {key}") + else: + raise RuntimeError(f"Receive path_or_stream type: {type(path_or_stream)}, only support string, Path or BytesIO") def _load_document(self, key: str, filename: str) -> bool: """Load a document by key and filename.