Interface DoclingServeConvertApi

All Known Subinterfaces:
DoclingServeApi

public interface DoclingServeConvertApi
Interface representing the Docling Serve Convert API. This API is responsible for processing and converting document source(s) into a structured or processed document format based on the specified conversion options.
  • Method Details

    • convertSource

      Converts the provided document source(s) into a processed document based on the specified options.
      Parameters:
      request - the ConvertDocumentRequest containing the source(s), conversion options, and optional target.
      Returns:
      a ConvertDocumentResponse describing the convert document response.
      Throws:
      ValidationException - If request validation fails for any reason.
    • convertFiles

      default ConvertDocumentResponse convertFiles(Path... files)
      Converts the specified files into a processed document using default options. This is a convenience method that delegates to convertFiles(ConvertDocumentRequest, Path...) with a null request.
      Parameters:
      files - an array of Path objects representing the file paths to be converted
      Returns:
      a ConvertDocumentResponse containing the processed document data, metadata, and any errors
      Throws:
      ValidationException - If request validation fails for any reason.
    • convertFiles

      default ConvertDocumentResponse convertFiles(@Nullable ConvertDocumentRequest request, Path... files)
      Converts the specified files into a processed document based on the options provided in the request. If the request is null, default conversion options are applied.
      Parameters:
      request - an optional ConvertDocumentRequest specifying conversion settings and parameters
      files - an array of Path objects representing the file paths to be converted
      Returns:
      a ConvertDocumentResponse containing the processed document data, any errors encountered, and additional processing metadata
      Throws:
      ValidationException - If request validation fails for any reason.
    • convertSourceAsync

      Initiates an asynchronous conversion of the provided document source(s) and returns a CompletionStage that completes when the conversion is done.

      This method starts the conversion, polls the status in the background, and completes the future with the result when the conversion finishes.

      Example usage:

      
       client.convertSourceAsync(request)
           .thenApply(response -> response.getDocument().getMarkdownContent())
           .thenAccept(markdown -> System.out.println(markdown))
           .exceptionally(ex -> { ex.printStackTrace(); return null; });
       
      Parameters:
      request - the ConvertDocumentRequest containing the source(s) and conversion options.
      Returns:
      a CompletionStage that completes with the ConvertDocumentResponse when the conversion is finished, or completes exceptionally if the conversion fails or times out.
      Throws:
      ValidationException - If request validation fails for any reason.
    • convertFilesAsync

      default CompletionStage<ConvertDocumentResponse> convertFilesAsync(Path... files)
      Initiates an asynchronous conversion of the provided files into a processed document using default conversion options.
      Parameters:
      files - an array of Path objects representing the file paths to be converted
      Returns:
      a CompletionStage that completes with the ConvertDocumentResponse when the conversion finishes, or completes exceptionally if the conversion fails or times out
      Throws:
      ValidationException - If request validation fails for any reason.
    • convertFilesAsync

      default CompletionStage<ConvertDocumentResponse> convertFilesAsync(@Nullable ConvertDocumentRequest request, Path... files)
      Initiates an asynchronous conversion of the specified files into a processed document using the provided conversion request options. If the request is null, default conversion options are applied.
      Parameters:
      request - an optional ConvertDocumentRequest containing conversion settings and parameters, or null to use default options
      files - an array of Path objects representing the file paths to be converted
      Returns:
      a CompletionStage that completes with the ConvertDocumentResponse when the conversion finishes, or completes exceptionally if the conversion fails or times out
      Throws:
      ValidationException - If request validation fails for any reason.