Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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

}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -97,6 +107,7 @@ public class DocumentResponse {
* <p>Builder methods:
* <ul>
* <li>{@code doctagsContent(String)} - Set the DocTags content</li>
* <li>{@code doclangContent(String)} - Set the DocLang content</li>
* <li>{@code filename(String)} - Set the filename</li>
* <li>{@code htmlContent(String)} - Set the HTML content</li>
* <li>{@code jsonContent(DoclingDocument)} - Set the JSON content</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class DocumentResponseTests {
@Test
void createResponseWithAllFields() {
String doctagsContent = "doctags content";
String doclangContent = "doclang content";
String filename = "test-document.pdf";
String htmlContent = "<html><body>Test content</body></html>";
DoclingDocument doclingDocument = DoclingDocument.builder()
Expand All @@ -29,6 +30,7 @@ void createResponseWithAllFields() {

DocumentResponse response = DocumentResponse.builder()
.doctagsContent(doctagsContent)
.doclangContent(doclangContent)
.filename(filename)
.htmlContent(htmlContent)
.jsonContent(doclingDocument)
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions docs/src/doc/docs/whats-new.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. `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.
* **`docling-testcontainers` default image bumped to `v1.41.0`** — `DoclingServeContainerConfig.DOCLING_IMAGE` now pins `ghcr.io/docling-project/docling-serve:v1.41.0` (previously `v1.35.0`). `ConvertDocumentOptions` is unchanged across this range, but one behavioral difference will show up for consumers relying on the previous default: a single-file conversion with `ZipTarget` now names the archive after the source file (e.g. `2408.09869.zip`) instead of the generic `converted_docs.zip`; multi-file conversions are unaffected. Preset registration remains image-specific — see the warning in [Per-stage presets and custom configurations](docling-serve/serve-api.md#per-stage-presets-and-custom-configurations).
* **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 `<stage>Preset` string or a `<stage>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<String, Object>` 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.
Expand Down