docling-core: export DoclingDocument to markdown/text locally (Python parity)
DoclingDocument in Java deserializes from JSON, but there is no local export API (export_to_markdown() / text) like in Python.
We persist Docling JSON as canonical artifact and need text/md in later (async) document processing stages (moderation, etc.) without re-parsing the original file and without a Serve round-trip (JSON_DOCLING → md|text works but adds HTTP coupling).
Proposal: add local export in docling-core, e.g. toMarkdown() / toText().
Use case: offline/async workers reading archived JSON only.
Can't you receive the export in both Markdown and json from the api? In your request you can ask for both JSON & Markdown and in DocumentResponse there is both the jsonContent (the DoclingDocument) and markdownContent (as well as textContent and htmlContent)
That makes sense — requesting both formats up front would work.
The reason I'm asking for local export is that I intentionally persist only the Docling JSON as the canonical artifact. Hybrid chunking already consumes JSON_DOCLING directly, while Markdown/text are derived representations that other downstream stages (e.g. moderation) may need later.
So rather than storing multiple representations, I'd prefer to store only the JSON and derive Markdown/text from the archived DoclingDocument when needed, ideally without another Serve round-trip.
This API is just a wrapper around docling-serve. It doesn't really do anything on its own. The Java API doesn't do any processing on its own.
That being said let me do some investigation and see if there's anything possible. If the conversion involves some logic performed by Docling itself then unfortunately we won't be able to do that here.
But I'll do some investigation.