This is an automated email from the ASF dual-hosted git repository.

fmariani pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot-examples.git


The following commit(s) were added to refs/heads/main by this push:
     new 94e9ed7  Adding docling-serve example
94e9ed7 is described below

commit 94e9ed765a3367f6678a497daea25bbc8269cafd
Author: Salvatore Mongiardo <[email protected]>
AuthorDate: Mon Feb 16 16:10:51 2026 +0100

    Adding docling-serve example
---
 README.adoc                                        |   4 +-
 docling/.gitignore                                 |  11 ++
 docling/pom.xml                                    | 112 +++++++++++++++++++++
 docling/readme.adoc                                | 108 ++++++++++++++++++++
 .../docling/DoclingServeApplication.java           |  28 ++++++
 .../springboot/docling/DoclingServeRoute.java      |  46 +++++++++
 docling/src/main/resources/application.properties  |  19 ++++
 docling/src/main/resources/documents/.gitkeep      |   0
 .../src/main/resources/documents/extract/.gitkeep  |   0
 docling/src/main/resources/output/.gitkeep         |   0
 .../src/main/resources/output/metadata/.gitkeep    |   0
 docling/src/main/resources/sample-document.pdf     | Bin 0 -> 138065 bytes
 pom.xml                                            |   1 +
 13 files changed, 328 insertions(+), 1 deletion(-)

diff --git a/README.adoc b/README.adoc
index 40fcafa..b95c2c1 100644
--- a/README.adoc
+++ b/README.adoc
@@ -27,7 +27,7 @@ readme's instructions.
 === Examples
 
 // examples: START
-Number of Examples: 68 (0 deprecated)
+Number of Examples: 69 (0 deprecated)
 
 [width="100%",cols="4,2,4",options="header"]
 |===
@@ -89,6 +89,8 @@ Number of Examples: 68 (0 deprecated)
 
 | link:multi-datasource-2pc/readme.adoc[Multi Datasource 2pc] 
(multi-datasource-2pc) | Database | An example showing how to work with Camel 
and Spring Boot using multiple pooled datasources with two-phase commit
 
+| link:docling/readme.adoc[Docling] (docling) | Document Processing | An 
example showing how to convert documents to Markdown using Camel Docling 
component and Spring Boot
+
 | link:load-balancer-eip/README.adoc[Load Balancer Eip] (load-balancer-eip) | 
EIP | An example showing Load Balancer EIP with Camel and Spring Boot
 
 | link:platform-http-proxy/README.adoc[Platform Http Proxy] 
(platform-http-proxy) | EIP | An example showing Camel reverse proxy with 
platform HTTP
diff --git a/docling/.gitignore b/docling/.gitignore
new file mode 100644
index 0000000..4022d87
--- /dev/null
+++ b/docling/.gitignore
@@ -0,0 +1,11 @@
+target/
+src/main/resources/documents/*
+!src/main/resources/documents/.gitkeep
+!src/main/resources/documents/extract/
+src/main/resources/documents/extract/*
+!src/main/resources/documents/extract/.gitkeep
+src/main/resources/output/*
+!src/main/resources/output/.gitkeep
+!src/main/resources/output/metadata/
+src/main/resources/output/metadata/*
+!src/main/resources/output/metadata/.gitkeep
diff --git a/docling/pom.xml b/docling/pom.xml
new file mode 100644
index 0000000..1494a24
--- /dev/null
+++ b/docling/pom.xml
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+      <groupId>org.apache.camel.springboot.example</groupId>
+      <artifactId>examples</artifactId>
+      <version>4.18.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>camel-example-spring-boot-docling</artifactId>
+    <name>Camel SB Examples :: Docling</name>
+    <description>An example showing how to convert documents to Markdown using 
Camel Docling component and Spring Boot</description>
+
+    <properties>
+        <category>Document Processing</category>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+    </properties>
+
+    <dependencyManagement>
+        <dependencies>
+            <!-- Spring Boot BOM -->
+            <dependency>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-dependencies</artifactId>
+                <version>${spring-boot-version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+            <!-- Camel BOM -->
+            <dependency>
+                <groupId>org.apache.camel.springboot</groupId>
+                <artifactId>camel-spring-boot-bom</artifactId>
+                <version>${project.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+        <!-- Spring Boot -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter</artifactId>
+        </dependency>
+
+        <!-- Camel -->
+        <dependency>
+            <groupId>org.apache.camel.springboot</groupId>
+            <artifactId>camel-spring-boot-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.springboot</groupId>
+            <artifactId>camel-docling-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.springboot</groupId>
+            <artifactId>camel-file-starter</artifactId>
+        </dependency>
+
+        <!-- test -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test-spring-junit5</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>${spring-boot-version}</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/docling/readme.adoc b/docling/readme.adoc
new file mode 100644
index 0000000..8082d2e
--- /dev/null
+++ b/docling/readme.adoc
@@ -0,0 +1,108 @@
+== Camel Example Spring Boot and Docling
+
+This example shows how to work with Apache Camel and the Docling component 
using Spring Boot to convert documents to Markdown format.
+
+The example demonstrates document conversion from various formats (PDF, DOCX, 
PPTX, HTML, MD) to Markdown using the Docling service.
+
+=== Features
+
+* Document to Markdown Conversion - Automatically converts PDF, DOCX, PPTX, 
HTML, and MD files to Markdown format
+* Metadata Extraction - Optional route to extract structured data as JSON from 
documents
+* File-based Processing - Watch directories for new files and process them 
automatically
+* Java DSL Routes - Routes defined using Camel Java DSL
+
+=== Prerequisites
+
+Before running this example, you need:
+
+1. A running Docling-Serve instance at http://localhost:5001
+
+----
+docker run -p 5001:5001 -e DOCLING_SERVE_ENABLE_UI=1 
ghcr.io/docling-project/docling-serve:latest
+----
+
+=== How to run
+
+You can run this example using:
+
+----
+mvn spring-boot:run
+----
+
+=== Usage
+
+==== Converting Documents to Markdown
+
+1. Start the application
+2. Place any PDF, DOCX, PPTX, HTML, or MD file in the 
`src/main/resources/documents/` directory
+3. The application will:
+   - Detect the new file
+   - Convert it to Markdown using Docling
+   - Save the converted file to `src/main/resources/output/` directory with 
`.md` extension
+   - Delete the original file from `src/main/resources/documents/`
+
+==== Extracting Structured Metadata
+
+1. Place documents in `src/main/resources/documents/extract/`
+2. The application will:
+   - Extract structured data from the document
+   - Save the metadata as JSON to `src/main/resources/output/metadata/`
+
+=== Project Structure
+
+----
+docling/
+└── src/
+    └── main/
+        ├── java/
+        │   └── org/apache/camel/example/springboot/docling/
+        │       ├── DoclingServeApplication.java
+        │       └── DoclingServeRoute.java
+        └── resources/
+            ├── application.properties
+            ├── documents/              # Input directory - place documents 
here
+            │   └── extract/           # Optional: place documents here for 
metadata extraction
+            └── output/                # Output directory for converted 
Markdown files
+                └── metadata/         # Output directory for extracted 
metadata JSON files
+----
+
+=== Configuration
+
+Edit `src/main/resources/application.properties` to configure:
+
+* `docling.serve.url` - URL of the Docling service
+* `documents.directory` - Input directory for documents to convert (default: 
src/main/resources/documents)
+* `output.directory` - Output directory for converted files (default: 
src/main/resources/output)
+
+=== Routes
+
+The application includes two routes defined in 
`src/main/java/org/apache/camel/example/springboot/docling/DoclingServeRoute.java`:
+
+==== document-to-markdown-converter
+
+* Watches: `src/main/resources/documents/` directory
+* Accepts: PDF, DOCX, PPTX, HTML, MD files
+* Action: Converts to Markdown
+* Output: `src/main/resources/output/{filename}.md`
+
+==== document-metadata-extractor
+
+* Watches: `src/main/resources/documents/extract/` directory
+* Accepts: PDF, DOCX, PPTX files
+* Action: Extracts structured data as JSON
+* Output: `src/main/resources/output/metadata/{filename}.json`
+
+=== Using Camel components
+
+Apache Camel provides 200+ components which you can use to integrate and route 
messages between many systems
+and data formats. To use any of these Camel components, add the component as a 
dependency to your project.
+
+=== Help and contributions
+
+If you hit any problem using Camel or have some feedback, then please
+https://camel.apache.org/support.html[let us know].
+
+We also love contributors, so
+https://camel.apache.org/contributing.html[get involved] :-)
+
+The Camel riders!
diff --git 
a/docling/src/main/java/org/apache/camel/example/springboot/docling/DoclingServeApplication.java
 
b/docling/src/main/java/org/apache/camel/example/springboot/docling/DoclingServeApplication.java
new file mode 100644
index 0000000..805e3dd
--- /dev/null
+++ 
b/docling/src/main/java/org/apache/camel/example/springboot/docling/DoclingServeApplication.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.example.springboot.docling;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class DoclingServeApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(DoclingServeApplication.class, args);
+    }
+}
diff --git 
a/docling/src/main/java/org/apache/camel/example/springboot/docling/DoclingServeRoute.java
 
b/docling/src/main/java/org/apache/camel/example/springboot/docling/DoclingServeRoute.java
new file mode 100644
index 0000000..bfa27ab
--- /dev/null
+++ 
b/docling/src/main/java/org/apache/camel/example/springboot/docling/DoclingServeRoute.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.example.springboot.docling;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.stereotype.Component;
+
+@Component
+public class DoclingServeRoute extends RouteBuilder {
+
+    @Override
+    public void configure() throws Exception {
+
+        
from("file:{{documents.directory}}?delete=true&include=.*\\.(pdf|docx|pptx|html|md)$")
+            .routeId("document-to-markdown-converter")
+            .log("Processing document: ${header.CamelFileName}")
+            
.to("docling:CONVERT_TO_MARKDOWN?useDoclingServe=true&doclingServeUrl={{docling.serve.url}}&contentInBody=true")
+            .log("Document converted to Markdown: ${header.CamelFileName}")
+            .setHeader("CamelFileName", simple("${file:name.noext}.md"))
+            .to("file:{{output.directory}}")
+            .log("Saved converted document to: 
{{output.directory}}/${header.CamelFileName}");
+
+        
from("file:{{documents.directory}}/extract?delete=true&include=.*\\.(pdf|docx|pptx)$")
+            .routeId("document-metadata-extractor")
+            .log("Extracting metadata from: ${header.CamelFileName}")
+            
.to("docling:EXTRACT_STRUCTURED_DATA?useDoclingServe=true&doclingServeUrl={{docling.serve.url}}&outputFormat=json&contentInBody=true")
+            .log("Metadata extracted from: ${header.CamelFileName}")
+            .setHeader("CamelFileName", simple("${file:name.noext}.json"))
+            .to("file:{{output.directory}}/metadata")
+            .log("Saved metadata to: 
{{output.directory}}/metadata/${header.CamelFileName}");
+    }
+}
diff --git a/docling/src/main/resources/application.properties 
b/docling/src/main/resources/application.properties
new file mode 100644
index 0000000..6023c5b
--- /dev/null
+++ b/docling/src/main/resources/application.properties
@@ -0,0 +1,19 @@
+# Application Configuration
+camel.main.name=DoclingServe
+spring.application.name=camel-docling-serve
+
+# Directory Configuration
+documents.directory=src/main/resources/documents
+output.directory=src/main/resources/output
+
+# Docling Service Configuration
+docling.serve.url=http://localhost:5001
+
+# Camel Route Configuration
+camel.main.run-controller=true
+
+# Logging Configuration
+#logging.level.org.apache.camel=INFO
+#logging.level.org.springframework = INFO
+#logging.level.org.apache.camel.spring.boot = INFO
+#logging.level.org.apache.camel.example.springboot.docling=DEBUG
diff --git a/docling/src/main/resources/documents/.gitkeep 
b/docling/src/main/resources/documents/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/docling/src/main/resources/documents/extract/.gitkeep 
b/docling/src/main/resources/documents/extract/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/docling/src/main/resources/output/.gitkeep 
b/docling/src/main/resources/output/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/docling/src/main/resources/output/metadata/.gitkeep 
b/docling/src/main/resources/output/metadata/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/docling/src/main/resources/sample-document.pdf 
b/docling/src/main/resources/sample-document.pdf
new file mode 100644
index 0000000..0b76736
Binary files /dev/null and b/docling/src/main/resources/sample-document.pdf 
differ
diff --git a/pom.xml b/pom.xml
index f067094..0e355e3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -45,6 +45,7 @@
                <module>artemis</module>
                <module>aws-secrets-manager</module>
                <module>aws2-s3</module>
+               <module>docling</module>
                <module>endpointdsl</module>
                <module>groovy</module>
                <module>fhir</module>

Reply via email to