From 1b1af3d68c05652627d86227c9ac350e919698ea Mon Sep 17 00:00:00 2001 From: Christoph Auer Date: Mon, 16 Sep 2024 16:02:48 +0200 Subject: [PATCH] Initialize docling PDF parser on module level Signed-off-by: Christoph Auer --- docling/backend/docling_parse_backend.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docling/backend/docling_parse_backend.py b/docling/backend/docling_parse_backend.py index d7a116d..594f80c 100644 --- a/docling/backend/docling_parse_backend.py +++ b/docling/backend/docling_parse_backend.py @@ -14,6 +14,8 @@ _log = logging.getLogger(__name__) +pdf_parser = pdf_parser() + class DoclingParsePageBackend(PdfPageBackend): def __init__( @@ -190,7 +192,7 @@ def __init__(self, path_or_stream: Union[BytesIO, Path], document_hash: str): super().__init__(path_or_stream, document_hash) self._pdoc = pdfium.PdfDocument(path_or_stream) - self.parser = pdf_parser() + self.parser = pdf_parser success = False if isinstance(path_or_stream, BytesIO):