Class Docling
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 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 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.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
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)insertPageNumbers- whentrue, inserts a---- Page N ----marker line at the start of each page's content. Page boundaries come from docling's JSON output, so this runs a single conversion that also emits JSON. To keep that JSON small and fast (its only purpose here is page provenance), images are exported as placeholders rather than embedded, so the Markdown produced in this mode contains image placeholders instead of inline base64 images. Best-effort: pages with no locatable text are left unmarked.- Returns:
- the generated Markdown
- Throws:
DoclingException- if docling cannot be launched, times out, or exits non-zero
-
convert
-
convert
-
convert
Converts a local file to Markdown and returns it as a string.- Parameters:
source- path of the document to convertremoveBase64Images- whentrue, strips base64-embedded images from the outputinsertPageNumbers- whentrue, inserts a---- Page N ----marker at the start of each page (seeconvert(String, boolean, boolean))
-
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
-
convert
public String convert(byte[] data, String extension, boolean removeBase64Images, boolean insertPageNumbers) 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 outputinsertPageNumbers- whentrue, inserts a---- Page N ----marker at the start of each page (seeconvert(String, boolean, boolean))- 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
-