Source code for cadrumo.adapters.inbound.borrador._parsers.pdfplumber_backend
"""Pdfplumber-backed page text extraction for Modelo 100 PDFs.Implements the single``adapters.inbound.borrador._parsers._pdfplumber_backend.extract_pages_text``primitive that the borrador extractors consume. The function isolates thepdfplumber dependency so other backends (e.g. pdfminer, OCR) can be swapped inwithout touching extractor code.The backend delegates to:func:`~adapters.inbound.pdf.page_text_extraction.extract_pages_text_from_path` andwraps failures in :class:`~adapters.inbound.borrador.errors.BorradorParseError`so callers stay inside the borrador parse-error family."""from__future__importannotationsfrompathlibimportPathfrom...pdf.page_text_extractionimportextract_pages_text_from_pathfrom..errorsimportBorradorParseError
[docs]defextract_pages_text(pdf_path:Path)->tuple[str,...]:"""Extract stripped text from each Modelo 100 PDF page in order. Args: pdf_path: Path to the PDF whose pages will be read. Returns: A tuple of stripped per-page text strings, in page order. Raises: BorradorParseError: When the source path is missing or the PDF backend cannot extract page text. """returnextract_pages_text_from_path(pdf_path,error_class=BorradorParseError,not_found_label="Modelo 100 PDF not found",pdf_label="PDF",)