is PdfPipelineOptions only suitable for pdfs or does it work good for other types of documents as well
tell me if we have to use any thing else other pdfpipeline option so that it is ideal for all types of documents
PdfPipelineOptions is specifically designed for processing PDFs and image-rich documents. It includes features like OCR, table structure extraction, and image enrichment that are tailored for PDFs and scanned images, not for general document types like DOCX, Markdown, or HTML. For non-PDF documents, you should use other pipeline options: SimplePipeline is recommended for DOCX, Markdown, and HTML, while VlmPipeline is used for vision-language model inference on formats like Markdown, HTML, and Doctags. Using the appropriate pipeline for each document type ensures optimal results and performance [source].
To reply, just mention @dosu.
Docs are dead. Just use Dosu.
if i want to build a code which supports all types of documents in an ideal way how should i do it explain me clearly with the help of a code snippet
To support all document types in Docling, use the DocumentConverter class. It automatically detects the document format (PDF, DOCX, Markdown, HTML, images, CSV, etc.) using file extension, MIME type, and content inspection, then routes each document to the ideal pipeline (StandardPdfPipeline for PDFs/images, SimplePipeline for DOCX/Markdown/HTML, etc.) for conversion. You don't need to manually select the pipeline—just pass your files or streams to DocumentConverter and it handles everything for you [source].
Here’s a clear example:
from docling.document_converter import DocumentConverter
# Create a converter (optionally restrict allowed formats)
converter = DocumentConverter()
# Convert a single file (PDF, DOCX, MD, HTML, image, etc.)
result = converter.convert("path/to/your/document.pdf")
# result = converter.convert("path/to/your/document.docx")
# result = converter.convert("path/to/your/document.md")
# result = converter.convert("path/to/your/image.png")
# Convert multiple files at once
results = converter.convert_all([
"file1.pdf",
"file2.docx",
"file3.md",
"image1.png"
])
for res in results:
print(res.status, res.input.file, res.document)
# Convert a string (Markdown or HTML)
md_content = "# Hello\nThis is markdown."
md_result = converter.convert_string(md_content, format="md", name="example.md")
html_content = "<h1>Hello</h1>"
html_result = converter.convert_string(html_content, format="html", name="example.html")
Docling will pick the right pipeline for each file type and handle conversion, enrichment, and error handling. You can extend this by customizing FormatOption or adding new pipelines if you need to support additional formats or custom logic [source].
Edge cases: If a file type isn’t supported or is ambiguous, Docling will raise an error or mark the result as failure. For advanced customization or error handling, you can subclass DocumentConverter or tweak pipeline options.
Let me know if you want details on customizing pipelines or handling specific formats!
To reply, just mention @dosu.
Docs are dead. Just use Dosu.