The simplest way to get started with Docling is to convert a single document and print the output.
Quick Example
This example converts a PDF from a URL and prints the Markdown output to stdout.
from docling.document_converter import DocumentConverter
# Change this to a local path or another URL if desired.
# Note: using the default URL requires network access; if offline, provide a
# local file path (e.g., Path("/path/to/file.pdf")).
source = "https://arxiv.org/pdf/2408.09869"
converter = DocumentConverter()
result = converter.convert(source)
# Print Markdown to stdout.
print(result.document.export_to_markdown())
How It Works
Import the Converter
Import DocumentConverter from the docling package.
Specify the Source
Provide a URL or local file path. Docling auto-detects the format (PDF, DOCX, HTML, PPTX, images, etc.).
Convert the Document
Call converter.convert(source) to process the document.
Export to Markdown
Use result.document.export_to_markdown() to get the converted text.
The converter auto-detects supported formats including PDF, DOCX, HTML, PPTX, images, and more.
Requirements
- Python 3.9+
- Install Docling:
pip install docling
Running the Example
python docs/examples/minimal.py
For batch processing or saving outputs to files, see Batch Conversion.