From 3165db075c5e279de60d9a03bdca36c83917accb Mon Sep 17 00:00:00 2001 From: Eric Deandrea Date: Tue, 1 Dec 2026 13:42:44 -0500 Subject: [PATCH 1/2] feat(api): add missing OutputFormat values and doclangContent OutputFormat only declared 6 of the 12 values Docling Serve supports, so callers could not request yaml, vtt, doclang, dclx, or latex output (chunks is left for the convert-side chunking work). DocumentResponse gains a matching doclangContent accessor, since Docling Serve returns doclang_content inline the same way it does for the existing formats. The other four new formats have no inline content field on the server today; like the existing HTML_SPLIT_PAGE, they are only reachable through file-based targets such as a zip archive or a presigned URL. Related to #822. Assisted-By: Claude Code Signed-off-by: Eric Deandrea --- .../convert/request/options/OutputFormat.java | 28 +++++++++--- .../convert/response/DocumentResponse.java | 11 +++++ .../response/DocumentResponseTests.java | 5 +++ .../AbstractDoclingServeClientTests.java | 45 +++++++++++++++++++ docs/src/doc/docs/whats-new.md | 1 + 5 files changed, 84 insertions(+), 6 deletions(-) diff --git a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/request/options/OutputFormat.java b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/request/options/OutputFormat.java index 6700a419..b23bdfb9 100644 --- a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/request/options/OutputFormat.java +++ b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/request/options/OutputFormat.java @@ -7,11 +7,27 @@ */ public enum OutputFormat { - @JsonProperty("doctags") DOCTAGS, - @JsonProperty("html") HTML, - @JsonProperty("html_split_page") HTML_SPLIT_PAGE, - @JsonProperty("json") JSON, - @JsonProperty("md") MARKDOWN, - @JsonProperty("text") TEXT + @JsonProperty("dclx") + DCLX, + @JsonProperty("doctags") + DOCTAGS, + @JsonProperty("doclang") + DOCLANG, + @JsonProperty("html") + HTML, + @JsonProperty("html_split_page") + HTML_SPLIT_PAGE, + @JsonProperty("json") + JSON, + @JsonProperty("latex") + LATEX, + @JsonProperty("md") + MARKDOWN, + @JsonProperty("text") + TEXT, + @JsonProperty("vtt") + VTT, + @JsonProperty("yaml") + YAML } diff --git a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/DocumentResponse.java b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/DocumentResponse.java index 26de6f0a..c3f29cda 100644 --- a/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/DocumentResponse.java +++ b/docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/DocumentResponse.java @@ -41,6 +41,16 @@ public class DocumentResponse { @Nullable private String doctagsContent; + /** + * Document content in DocLang format (if requested). + * + * @param doclangContent the DocLang content, or null if not requested + * @return the DocLang content, or null if not requested + */ + @JsonProperty("doclang_content") + @Nullable + private String doclangContent; + /** * Filename of the source document. * @@ -97,6 +107,7 @@ public class DocumentResponse { *

Builder methods: *

    *
  • {@code doctagsContent(String)} - Set the DocTags content
  • + *
  • {@code doclangContent(String)} - Set the DocLang content
  • *
  • {@code filename(String)} - Set the filename
  • *
  • {@code htmlContent(String)} - Set the HTML content
  • *
  • {@code jsonContent(DoclingDocument)} - Set the JSON content
  • diff --git a/docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/response/DocumentResponseTests.java b/docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/response/DocumentResponseTests.java index 5bc4adea..fa0bf8e4 100644 --- a/docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/response/DocumentResponseTests.java +++ b/docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/response/DocumentResponseTests.java @@ -18,6 +18,7 @@ class DocumentResponseTests { @Test void createResponseWithAllFields() { String doctagsContent = "doctags content"; + String doclangContent = "doclang content"; String filename = "test-document.pdf"; String htmlContent = "Test content"; DoclingDocument doclingDocument = DoclingDocument.builder() @@ -29,6 +30,7 @@ void createResponseWithAllFields() { DocumentResponse response = DocumentResponse.builder() .doctagsContent(doctagsContent) + .doclangContent(doclangContent) .filename(filename) .htmlContent(htmlContent) .jsonContent(doclingDocument) @@ -37,6 +39,7 @@ void createResponseWithAllFields() { .build(); assertThat(response.getDoctagsContent()).isEqualTo(doctagsContent); + assertThat(response.getDoclangContent()).isEqualTo(doclangContent); assertThat(response.getFilename()).isEqualTo(filename); assertThat(response.getHtmlContent()).isEqualTo(htmlContent); assertThat(response.getJsonContent()).isNotNull(); @@ -51,6 +54,7 @@ void createResponseWithNullFields() { DocumentResponse response = DocumentResponse.builder().build(); assertThat(response.getDoctagsContent()).isNull(); + assertThat(response.getDoclangContent()).isNull(); assertThat(response.getFilename()).isNull(); assertThat(response.getHtmlContent()).isNull(); assertThat(response.getJsonContent()).isNull(); @@ -71,6 +75,7 @@ void createResponseWithEmptyFields() { .build(); assertThat(response.getDoctagsContent()).isNull(); + assertThat(response.getDoclangContent()).isNull(); assertThat(response.getFilename()).isEqualTo(filename); assertThat(response.getHtmlContent()).isNull(); assertThat(response.getJsonContent()).isNull(); diff --git a/docling-serve/docling-serve-client/src/test/java/ai/docling/serve/client/AbstractDoclingServeClientTests.java b/docling-serve/docling-serve-client/src/test/java/ai/docling/serve/client/AbstractDoclingServeClientTests.java index 96b483c7..7bebcf91 100644 --- a/docling-serve/docling-serve-client/src/test/java/ai/docling/serve/client/AbstractDoclingServeClientTests.java +++ b/docling-serve/docling-serve-client/src/test/java/ai/docling/serve/client/AbstractDoclingServeClientTests.java @@ -1431,6 +1431,51 @@ void shouldConvertFileSuccessfully() { assertThat(inBodyResponse.getDocument().getMarkdownContent()).isNotEmpty(); } + @Test + void shouldConvertFileWithDoclangFormatSuccessfully() { + var options = ConvertDocumentOptions.builder() + .toFormat(OutputFormat.DOCLANG) + .build(); + + var request = ConvertDocumentRequest.builder() + .options(options) + .build(); + + var response = getDoclingClient().convertFiles(request, Path.of("src", "test", "resources", "story.pdf")); + assertThat(ResponseType.IN_BODY.equals(response.getResponseType())).isTrue(); + + var inBodyResponse = (InBodyConvertDocumentResponse) response; + + assertThat(inBodyResponse.getStatus()).isNotEmpty(); + assertThat(inBodyResponse.getDocument()).isNotNull(); + assertThat(inBodyResponse.getDocument().getDoclangContent()).isNotEmpty(); + } + + @Test + void shouldAcceptNewlySupportedOutputFormats() { + var options = ConvertDocumentOptions.builder() + .toFormat(OutputFormat.MARKDOWN) + .toFormat(OutputFormat.YAML) + .toFormat(OutputFormat.VTT) + .toFormat(OutputFormat.DCLX) + .toFormat(OutputFormat.LATEX) + .build(); + + var request = ConvertDocumentRequest.builder() + .options(options) + .build(); + + var response = getDoclingClient().convertFiles(request, Path.of("src", "test", "resources", "story.pdf")); + assertThat(ResponseType.IN_BODY.equals(response.getResponseType())).isTrue(); + + var inBodyResponse = (InBodyConvertDocumentResponse) response; + + // Only MARKDOWN has an inline content accessor; the other requested formats + // are accepted by the server but have no DocumentResponse field (like HTML_SPLIT_PAGE). + assertThat(inBodyResponse.getStatus()).isNotEmpty(); + assertThat(inBodyResponse.getDocument().getMarkdownContent()).isNotEmpty(); + } + @Test void shouldHandleConversionWithDifferentDocumentOptions() { var options = ConvertDocumentOptions.builder() diff --git a/docs/src/doc/docs/whats-new.md b/docs/src/doc/docs/whats-new.md index 96392b1e..8a1ec7d7 100644 --- a/docs/src/doc/docs/whats-new.md +++ b/docs/src/doc/docs/whats-new.md @@ -26,6 +26,7 @@ Docling Java {{ gradle.project_version }} includes important breaking changes, a ### {{ gradle.project_version }} +* **`OutputFormat` gains `YAML`, `VTT`, `DOCLANG`, `DCLX` and `LATEX`** — These were missing from the enum, so Docling Serve rejected `toFormats`/`toFormat` requests for them even though the server supports them. `DocumentResponse` also gains a `doclangContent` accessor, mirroring `doctagsContent`/`htmlContent`/etc., since Docling Serve returns `doclang_content` inline the same way it does for the existing formats. The other four new formats have no matching inline content field on the server today — like the existing `HTML_SPLIT_PAGE`, they are only reachable through file-based targets such as a zip archive or a presigned URL, not through an in-body response. * **Per-stage presets and custom configurations on `ConvertDocumentOptions`** — Eight pipeline stages (layout, OCR, table structure, picture description, picture classification, code & formula, chart extraction and the VLM pipeline) can now be tuned from Java, each through a `Preset` string or a `CustomConfig` map, for example `ocrPreset("easyocr")` or `layoutCustomConfigEntry("kind", "docling_layout_default")`. Presets are plain strings because the available ids are set by the Docling Serve deployment, so not even `"default"` is registered for every stage on every image. A custom config is a `Map` with a stage-specific schema, in one of two shapes: the kind-selected stages (layout, OCR, table structure, picture classification) pick an implementation through a `kind` entry, while the VLM-backed stages (picture description, code & formula, chart extraction, VLM pipeline) take `model_spec` and `engine_options` entries instead. The preset and the custom config are mutually exclusive per stage — a custom config replaces the preset rather than overriding it. These supersede `ocrEngine`, `pictureDescriptionLocal`, `pictureDescriptionApi` and the `vlmPipelineModel*` options, which Docling Serve marks as deprecated. * **The options Docling Serve deprecates are now `@Deprecated` in Java** — `ocrEngine`, `pictureDescriptionLocal`, `pictureDescriptionApi`, `vlmPipelineModel`, `vlmPipelineModelLocal` and `vlmPipelineModelApi` carry `@Deprecated(since = "0.7.3")`, which Lombok copies onto both the getter and the builder setter, so setting one produces a compiler warning pointing at the preset or custom-config replacement. They are deliberately **not** marked `forRemoval`: these options still work, and when they are removed is Docling Serve's decision rather than this library's. The four types that are only reachable through those options — `OcrEngine`, `VlmModelType`, `PictureDescriptionLocal` and `PictureDescriptionApi` — are marked `@Deprecated` as well, so the warning also appears at `PictureDescriptionApi.builder()` rather than only at the setter. * **New `doChartExtraction`, `includePageImages` and `mdCompactTables` options** — `doChartExtraction` extracts numeric data from charts, which had no workaround before. `includePageImages` generates full-page images, independently of `includeImages`, which covers picture elements only. `mdCompactTables` emits markdown tables without column padding, which is better for large tables and downstream processing. All three default to `false` on the server. From ed03493b07546ea5ddcf6fc9341dcd2c273d946d Mon Sep 17 00:00:00 2001 From: Eric Deandrea Date: Tue, 1 Dec 2026 14:06:02 -0500 Subject: [PATCH 2/2] docs(api): clarify DCLX vs. YAML/VTT/LATEX export support The previous wording implied all four non-doclang formats (yaml, vtt, dclx, latex) are reachable through file-based targets like the existing HTML_SPLIT_PAGE. Checked against docling-jobkit's convert/results.py and convert/export.py: only dclx actually has an export flag and a file-export implementation. yaml, vtt, and latex are accepted by the server's request validation but have no implemented export path at all, inline or file. Assisted-By: Claude Code Signed-off-by: Eric Deandrea --- docs/src/doc/docs/whats-new.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/doc/docs/whats-new.md b/docs/src/doc/docs/whats-new.md index 8a1ec7d7..915d6bed 100644 --- a/docs/src/doc/docs/whats-new.md +++ b/docs/src/doc/docs/whats-new.md @@ -26,7 +26,7 @@ Docling Java {{ gradle.project_version }} includes important breaking changes, a ### {{ gradle.project_version }} -* **`OutputFormat` gains `YAML`, `VTT`, `DOCLANG`, `DCLX` and `LATEX`** — These were missing from the enum, so Docling Serve rejected `toFormats`/`toFormat` requests for them even though the server supports them. `DocumentResponse` also gains a `doclangContent` accessor, mirroring `doctagsContent`/`htmlContent`/etc., since Docling Serve returns `doclang_content` inline the same way it does for the existing formats. The other four new formats have no matching inline content field on the server today — like the existing `HTML_SPLIT_PAGE`, they are only reachable through file-based targets such as a zip archive or a presigned URL, not through an in-body response. +* **`OutputFormat` gains `YAML`, `VTT`, `DOCLANG`, `DCLX` and `LATEX`** — These were missing from the enum, so Docling Serve rejected `toFormats`/`toFormat` requests for them even though the server supports them. `DocumentResponse` also gains a `doclangContent` accessor, mirroring `doctagsContent`/`htmlContent`/etc., since Docling Serve returns `doclang_content` inline the same way it does for the existing formats. `DCLX` has no inline content field but is exported as a file, reachable through file-based targets such as a zip archive or a presigned URL. `YAML`, `VTT`, and `LATEX` are accepted by the server's request validation but currently have no implemented export at all, inline or file — requesting them succeeds but produces nothing for those formats. * **Per-stage presets and custom configurations on `ConvertDocumentOptions`** — Eight pipeline stages (layout, OCR, table structure, picture description, picture classification, code & formula, chart extraction and the VLM pipeline) can now be tuned from Java, each through a `Preset` string or a `CustomConfig` map, for example `ocrPreset("easyocr")` or `layoutCustomConfigEntry("kind", "docling_layout_default")`. Presets are plain strings because the available ids are set by the Docling Serve deployment, so not even `"default"` is registered for every stage on every image. A custom config is a `Map` with a stage-specific schema, in one of two shapes: the kind-selected stages (layout, OCR, table structure, picture classification) pick an implementation through a `kind` entry, while the VLM-backed stages (picture description, code & formula, chart extraction, VLM pipeline) take `model_spec` and `engine_options` entries instead. The preset and the custom config are mutually exclusive per stage — a custom config replaces the preset rather than overriding it. These supersede `ocrEngine`, `pictureDescriptionLocal`, `pictureDescriptionApi` and the `vlmPipelineModel*` options, which Docling Serve marks as deprecated. * **The options Docling Serve deprecates are now `@Deprecated` in Java** — `ocrEngine`, `pictureDescriptionLocal`, `pictureDescriptionApi`, `vlmPipelineModel`, `vlmPipelineModelLocal` and `vlmPipelineModelApi` carry `@Deprecated(since = "0.7.3")`, which Lombok copies onto both the getter and the builder setter, so setting one produces a compiler warning pointing at the preset or custom-config replacement. They are deliberately **not** marked `forRemoval`: these options still work, and when they are removed is Docling Serve's decision rather than this library's. The four types that are only reachable through those options — `OcrEngine`, `VlmModelType`, `PictureDescriptionLocal` and `PictureDescriptionApi` — are marked `@Deprecated` as well, so the warning also appears at `PictureDescriptionApi.builder()` rather than only at the setter. * **New `doChartExtraction`, `includePageImages` and `mdCompactTables` options** — `doChartExtraction` extracts numeric data from charts, which had no workaround before. `includePageImages` generates full-page images, independently of `includeImages`, which covers picture elements only. `mdCompactTables` emits markdown tables without column padding, which is better for large tables and downstream processing. All three default to `false` on the server.