The generator builds this snippet for you. For PDFs it configures a PdfPipelineOptions object and registers it through format_options; for every other format a plain DocumentConverter() is enough.
from docling.document_converter import DocumentConverter, PdfFormatOption
from docling.datamodel.base_models import InputFormat
from docling.datamodel.pipeline_options import PdfPipelineOptions
pipeline_options = PdfPipelineOptions()
pipeline_options.do_ocr = True
pipeline_options.do_table_structure = True
converter = DocumentConverter(
format_options={InputFormat.PDF: PdfFormatOption(pipeline_options=pipeline_options)}
)
result = converter.convert("report.pdf")
print(result.document.export_to_markdown())
- Swap
export_to_markdown() for export_to_dict() to get lossless JSON.
- Set
pipeline_options.do_ocr = False to disable OCR.
- Use
convert_all() to process a batch of files.