This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new 7fbde8f8109 CAMEL-21305: enable PDF conversions with stream cache 7fbde8f8109 is described below commit 7fbde8f81098f91bc1c5bbd6b16238ea0ef106ca Author: Otavio Rodolfo Piske <angusyo...@gmail.com> AuthorDate: Wed Oct 2 13:34:26 2024 -0300 CAMEL-21305: enable PDF conversions with stream cache --- .../apache/camel/component/pdf/converter/PdfConverterLoader.java | 2 ++ .../org/apache/camel/component/pdf/converter/PdfConverter.java | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/components/camel-pdf/src/generated/java/org/apache/camel/component/pdf/converter/PdfConverterLoader.java b/components/camel-pdf/src/generated/java/org/apache/camel/component/pdf/converter/PdfConverterLoader.java index 41f878e6320..26ff3d42238 100644 --- a/components/camel-pdf/src/generated/java/org/apache/camel/component/pdf/converter/PdfConverterLoader.java +++ b/components/camel-pdf/src/generated/java/org/apache/camel/component/pdf/converter/PdfConverterLoader.java @@ -46,6 +46,8 @@ public final class PdfConverterLoader implements TypeConverterLoader, CamelConte private void registerConverters(TypeConverterRegistry registry) { addTypeConverter(registry, org.apache.pdfbox.pdmodel.PDDocument.class, byte[].class, false, (type, exchange, value) -> getPdfConverter().convertToPDF((byte[]) value)); + addTypeConverter(registry, org.apache.pdfbox.pdmodel.PDDocument.class, java.io.InputStream.class, false, + (type, exchange, value) -> getPdfConverter().toPDDocument((java.io.InputStream) value)); } private static void addTypeConverter(TypeConverterRegistry registry, Class<?> toType, Class<?> fromType, boolean allowNull, SimpleTypeConverter.ConversionMethod method) { diff --git a/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/converter/PdfConverter.java b/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/converter/PdfConverter.java index 4d236b512ba..322b11176af 100644 --- a/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/converter/PdfConverter.java +++ b/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/converter/PdfConverter.java @@ -17,6 +17,8 @@ package org.apache.camel.component.pdf.converter; +import java.io.InputStream; + import org.apache.camel.Converter; import org.apache.pdfbox.Loader; import org.apache.pdfbox.pdmodel.PDDocument; @@ -28,4 +30,10 @@ public class PdfConverter { public PDDocument convertToPDF(byte[] bytes) throws Exception { return Loader.loadPDF(bytes); } + + @Converter + public PDDocument toPDDocument(InputStream stream) throws Exception { + final byte[] bytes = stream.readAllBytes(); + return convertToPDF(bytes); + } }