Docling Integration#
RAGFlow's Go parser layer supports an external Docling Serve instance as a PDF parse method (parse_method: docling). The integration is entirely remote โ RAGFlow encodes the PDF as base64 and POSTs it to the Docling HTTP API; no in-process Docling library is used.
How it fits in the parser stack#
"docling" is one of several parse_method tokens recognized by PDFParser.ParseWithResult. When selected, it delegates to parsePDFWithDocling in internal/parser/parser/pdf_parser_docling.go.
The PDFParser struct holds two Docling-specific fields :
| Field | Env var fallback | Description |
|---|---|---|
DoclingServerURL | DOCLING_SERVER_URL | URL of the Docling Serve instance |
DoclingAPIKey | DOCLING_API_KEY | Optional Bearer token |
Both are populated by ConfigureFromSetup from the setup map (keys docling_server_url / docling_api_key), with env-var fallback applied at runtime .
Request flow#
parsePDFWithDocling tries four endpoint/format combinations in order, falling through on failure :
| Priority | Endpoint | Mode |
|---|---|---|
| 1 | /v1/convert/source | chunked |
| 2 | /v1alpha/convert/source | chunked |
| 3 | /v1/convert/source | standard |
| 4 | /v1alpha/convert/source | standard |
Chunked payload (doclingChunkedPayload) sends from_formats, to_formats, do_chunking, and chunking_options (max 512 tokens, 50-token overlap, sentencepiece tokenizer) .
Standard payload (doclingStandardPayload) sends only from_formats and to_formats .
Both payload builders omit do_ocr and pdf_backend entirely.
The missing do_ocr / pdf_backend options โ and why it matters#
Docling Serve's ConvertDocumentsOptions defaults to do_ocr=true and pdf_backend=threaded_docling_parse. Because RAGFlow never overrides these, every PDF is processed through Docling's OCR pipeline regardless of whether it contains selectable text .
On resource-constrained or non-GPU hosts (e.g., ARM/Raspberry Pi), the OCR path uses RapidOCR. For text-based (computer-generated) PDFs this produces empty or garbage output โ manifesting as the "RapidOCR returned empty result!" error reported in issue #20516.
The correct Docling behavior for text-based PDFs is:
do_ocr=falseโ skip the OCR pipelinepdf_backend=pypdfium2โ use the pypdfium2 backend to extract embedded text directly
Neither parameter is configurable through any RAGFlow setting, UI field, or environment variable today .
Current workaround#
Change Docling Serve's server-side defaults so that the server applies the correct options without needing the client to send them. There is no RAGFlow-side knob to pass do_ocr or pdf_backend per-request .
Key source files#
| File | Purpose |
|---|---|
internal/parser/parser/pdf_parser_docling.go | Full Docling integration: HTTP client, payload builders, response parsers |
internal/parser/parser/pdf_parser_common.go | PDFParser struct, ConfigureFromSetup, parse-method dispatch |
internal/common/environments.go | DOCLING_SERVER_URL / DOCLING_API_KEY env var constants |
docs/faq.mdx | Operational guide: setting server URL and API key |