MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / __init__

Method __init__

docling/backend/pdf_backend.py:47–60  ·  view source on GitHub ↗
(self, in_doc: InputDocument, path_or_stream: Union[BytesIO, Path])

Source from the content-addressed store, hash-verified

45
46class PdfDocumentBackend(PaginatedDocumentBackend):
47 def __init__(self, in_doc: InputDocument, path_or_stream: Union[BytesIO, Path]):
48 super().__init__(in_doc, path_or_stream)
49
50 if self.input_format is not InputFormat.PDF:
51 if self.input_format is InputFormat.IMAGE:
52 buf = BytesIO()
53 img = Image.open(self.path_or_stream)
54 img.save(buf, "PDF")
55 buf.seek(0)
56 self.path_or_stream = buf
57 else:
58 raise RuntimeError(
59 f"Incompatible file format {self.input_format} was passed to a PdfDocumentBackend."
60 )
61
62 @abstractmethod
63 def load_page(self, page_no: int) -> PdfPageBackend:

Callers

nothing calls this directly

Calls 1

saveMethod · 0.45

Tested by

no test coverage detected