Class Docling
java.lang.Object
org.docling.Docling
A thin, embeddable Java wrapper around the
docling command-line tool.
It does not reimplement conversion — it shells out to the docling executable, which
must be installed and on your PATH (e.g. pip install docling).
Typical usage:
Docling docling = Docling.builder().build();
String markdown = docling.convert("path/to/file.pdf");
Instances are immutable and safe to reuse across conversions.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic Docling.Builderbuilder()Creates a new builder with default settings (doclingon the PATH, 600s timeout).Converts in-memory document bytes to Markdown and returns it as a string.Converts in-memory document bytes to Markdown and returns it as a string.Converts the given source (local file path or URL) to Markdown and returns it as a string.Converts the given source (local file path or URL) to Markdown and returns it as a string.Converts a local file to Markdown and returns it as a string.Converts a local file to Markdown and returns it as a string.convertToDir(String source, Path outputDir) Converts the given source to Markdown, writing the.mdfile intooutputDir.
-
Method Details
-
builder
Creates a new builder with default settings (doclingon the PATH, 600s timeout). -
convert
Converts the given source (local file path or URL) to Markdown and returns it as a string.- Parameters:
source- path or URL of the document to convert- Returns:
- the generated Markdown
- Throws:
DoclingException- if docling cannot be launched, times out, or exits non-zero
-
convert
Converts the given source (local file path or URL) to Markdown and returns it as a string.- Parameters:
source- path or URL of the document to convertremoveBase64Images- whentrue, strips images embedded as base64 data URIs from the generated Markdown (bothand<img src="data:image/...">forms)- Returns:
- the generated Markdown
- Throws:
DoclingException- if docling cannot be launched, times out, or exits non-zero
-
convert
-
convert
-
convert
Converts in-memory document bytes to Markdown and returns it as a string.docling infers the input format from the file extension, so an
extensionmatching the data is required. The bytes are written to a temporary file (deleted afterwards) before being handed to docling.- Parameters:
data- the raw document bytes (e.g. the contents of a PDF or DOCX)extension- the file extension describing the data, with or without a leading dot (e.g."pdf",".docx")- Returns:
- the generated Markdown
- Throws:
DoclingException- if docling cannot be launched, times out, or exits non-zero
-
convert
Converts in-memory document bytes to Markdown and returns it as a string.docling infers the input format from the file extension, so an
extensionmatching the data is required. The bytes are written to a temporary file (deleted afterwards) before being handed to docling.- Parameters:
data- the raw document bytes (e.g. the contents of a PDF or DOCX)extension- the file extension describing the data, with or without a leading dot (e.g."pdf",".docx")removeBase64Images- whentrue, strips base64-embedded images from the output- Returns:
- the generated Markdown
- Throws:
DoclingException- if docling cannot be launched, times out, or exits non-zero
-
convertToDir
Converts the given source to Markdown, writing the.mdfile intooutputDir.- Parameters:
source- path or URL of the document to convertoutputDir- directory the Markdown file is written to (created if missing)- Returns:
- the path of the generated Markdown file
- Throws:
DoclingException- if docling cannot be launched, times out, or exits non-zero
-