A Java API for Docling
See the code
This is the repository for Docling Java, a Java API for using Docling.
Docling simplifies document processing, parsing diverse formats, including advanced PDF understanding, and providing seamless integrations with the Generative AI ecosystem.
See the documentation for complete information on the various artifacts that are provided by this project.
This project provides the following artifacts:
docling-core: Java API for working with the data types used by Docling for document representation (see Docling Core).docling-serve-api: Java API for interacting with a Docling Serve backend. It's frameworkβagnostic.docling-serve-client: A reference implementation of the docling-serve-api using Java's HttpClient and Jackson to connect to a Docling Serve endpoint.docling-testing: Utilities for testing Docling integration.docling-testcontainers: A Testcontainers module for running Docling in a Docker container.Use DoclingServeApi.convertSource() to convert individual documents (make sure both docling-serve-api and docling-serve-client are on your classpath).
For example:
import ai.docling.serve.api.DoclingServeApi;
import ai.docling.serve.api.convert.request.ConvertDocumentRequest;
import ai.docling.serve.api.convert.request.source.HttpSource;
import ai.docling.serve.api.convert.response.InBodyConvertDocumentResponse;
DoclingServeApi doclingServeApi = DoclingServeApi.builder()
.baseUrl("<location of docling serve instance>")
.build();
ConvertDocumentRequest request = ConvertDocumentRequest.builder()
.source(
HttpSource.builder()
.url(URI.create("https://arxiv.org/pdf/2408.09869"))
.build()
)
.build();
InBodyConvertDocumentResponse response = (InBodyConvertDocumentResponse) doclingServeApi.convertSource(request);
System.out.println(response.getDocument().getMarkdownContent());
If you're unsure of the concrete type returned by the convert API, you can handle it dynamically using the getResponseType() method:
import ai.docling.serve.api.convert.response.ResponseType;
// ... your code to create and configure the request ...
var result = doclingServeApi.convertSource(request);
switch(result.getResponseType()) {
case ResponseType.IN_BODY -> // Response is InBodyConvertDocumentResponse
case ResponseType.ZIP_ARCHIVE -> // Response is ZipArchiveConvertDocumentResponse
case ResponseType.PRE_SIGNED_URL -> // Response is PreSignedUrlConvertDocumentResponse
case ResponseType.PRE_SIGNED_URL_RESPONSE -> // Response is PreSignedUrlConvertResponse (with per-document artifact download URLs)
}
More usage information is available in the docs.
Please feel free to connect with us using the discussion section.
Please read Contributing to Docling Java for details.
The Docling codebase is under MIT license. For individual model usage, please refer to the model licenses found in the original packages.
The project was started by the AI for knowledge team at IBM Research Zurich.
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind are welcome!
285 commits
175 commits
82 commits
25 commits
Java
99.2%
A Java API for Docling
See the code
This is the repository for Docling Java, a Java API for using Docling.
Docling simplifies document processing, parsing diverse formats, including advanced PDF understanding, and providing seamless integrations with the Generative AI ecosystem.
See the documentation for complete information on the various artifacts that are provided by this project.
This project provides the following artifacts:
docling-core: Java API for working with the data types used by Docling for document representation (see Docling Core).docling-serve-api: Java API for interacting with a Docling Serve backend. It's frameworkβagnostic.docling-serve-client: A reference implementation of the docling-serve-api using Java's HttpClient and Jackson to connect to a Docling Serve endpoint.docling-testing: Utilities for testing Docling integration.docling-testcontainers: A Testcontainers module for running Docling in a Docker container.Use DoclingServeApi.convertSource() to convert individual documents (make sure both docling-serve-api and docling-serve-client are on your classpath).
For example:
import ai.docling.serve.api.DoclingServeApi;
import ai.docling.serve.api.convert.request.ConvertDocumentRequest;
import ai.docling.serve.api.convert.request.source.HttpSource;
import ai.docling.serve.api.convert.response.InBodyConvertDocumentResponse;
DoclingServeApi doclingServeApi = DoclingServeApi.builder()
.baseUrl("<location of docling serve instance>")
.build();
ConvertDocumentRequest request = ConvertDocumentRequest.builder()
.source(
HttpSource.builder()
.url(URI.create("https://arxiv.org/pdf/2408.09869"))
.build()
)
.build();
InBodyConvertDocumentResponse response = (InBodyConvertDocumentResponse) doclingServeApi.convertSource(request);
System.out.println(response.getDocument().getMarkdownContent());
If you're unsure of the concrete type returned by the convert API, you can handle it dynamically using the getResponseType() method:
import ai.docling.serve.api.convert.response.ResponseType;
// ... your code to create and configure the request ...
var result = doclingServeApi.convertSource(request);
switch(result.getResponseType()) {
case ResponseType.IN_BODY -> // Response is InBodyConvertDocumentResponse
case ResponseType.ZIP_ARCHIVE -> // Response is ZipArchiveConvertDocumentResponse
case ResponseType.PRE_SIGNED_URL -> // Response is PreSignedUrlConvertDocumentResponse
case ResponseType.PRE_SIGNED_URL_RESPONSE -> // Response is PreSignedUrlConvertResponse (with per-document artifact download URLs)
}
More usage information is available in the docs.
Please feel free to connect with us using the discussion section.
Please read Contributing to Docling Java for details.
The Docling codebase is under MIT license. For individual model usage, please refer to the model licenses found in the original packages.
The project was started by the AI for knowledge team at IBM Research Zurich.
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind are welcome!
285 commits
175 commits
82 commits
25 commits
Java
99.2%