camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [camel] branch master updated: CAMEL-11976: Align pdfbox versions to 2.0.6
Date Thu, 02 Nov 2017 12:08:40 GMT
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 7a43e60  CAMEL-11976: Align pdfbox versions to 2.0.6
7a43e60 is described below

commit 7a43e60e5add11b85e23daadca671aed8ef23adc
Author: Peter Palaga <ppalaga@redhat.com>
AuthorDate: Wed Nov 1 15:53:00 2017 +0100

    CAMEL-11976: Align pdfbox versions to 2.0.6
---
 components/camel-fop/pom.xml                       | 19 +++++--
 .../camel/component/fop/FopComponentTest.java      |  7 +--
 .../camel/component/fop/FopEndpointTest.java       |  9 ++--
 .../org/apache/camel/component/fop/FopHelper.java  | 19 +------
 .../camel/component/pdf/PdfConfiguration.java      | 20 ++++----
 .../apache/camel/component/pdf/PdfProducer.java    | 35 ++-----------
 .../camel/component/pdf/Standard14Fonts.java       | 59 ++++++++++++++++++++++
 .../component/pdf/text/DefaultWriteStrategy.java   |  2 +-
 .../apache/camel/component/pdf/text/PdfUtils.java  |  4 +-
 .../apache/camel/component/pdf/PdfAppendTest.java  | 13 ++---
 .../camel/component/pdf/PdfCreationTest.java       |  5 +-
 .../camel/component/pdf/PdfTextExtractionTest.java |  9 ++--
 parent/pom.xml                                     | 31 +++++++++++-
 .../karaf/features/src/main/resources/features.xml |  5 +-
 .../camel-spring-boot-dependencies/pom.xml         | 25 +++++++++
 15 files changed, 175 insertions(+), 87 deletions(-)

diff --git a/components/camel-fop/pom.xml b/components/camel-fop/pom.xml
index b328937..e463551 100644
--- a/components/camel-fop/pom.xml
+++ b/components/camel-fop/pom.xml
@@ -72,7 +72,7 @@
             <artifactId>avalon-framework-impl</artifactId>
             <version>${avalon-version}</version>
         </dependency>
-        
+
         <!-- for testing -->
         <dependency>
             <groupId>org.apache.camel</groupId>
@@ -82,10 +82,21 @@
         <dependency>
             <groupId>org.apache.pdfbox</groupId>
             <artifactId>pdfbox</artifactId>
-            <version>${pdfbox-version}</version>
             <scope>test</scope>
         </dependency>
-        
+        <dependency>
+            <groupId>org.bouncycastle</groupId>
+            <artifactId>bcprov-jdk15on</artifactId>
+            <version>${bouncycastle-version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.bouncycastle</groupId>
+            <artifactId>bcmail-jdk15on</artifactId>
+            <version>${bouncycastle-version}</version>
+            <scope>test</scope>
+        </dependency>
+
         <!-- Xalan Serializer dependencies are not  -->
         <!-- correctly imported from batik for tests  -->
         <!-- and as such they will fail. Must add to  -->
@@ -96,7 +107,7 @@
             <version>${xalan-version}</version>
             <scope>test</scope>
         </dependency>
-           
+
         <dependency>
             <groupId>org.apache.logging.log4j</groupId>
             <artifactId>log4j-api</artifactId>
diff --git a/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopComponentTest.java
b/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopComponentTest.java
index 7111ac3..249e111 100644
--- a/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopComponentTest.java
+++ b/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopComponentTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.fop;
 
+import java.io.File;
 import java.io.FileInputStream;
 
 import org.apache.camel.EndpointInject;
@@ -36,7 +37,7 @@ public class FopComponentTest extends CamelTestSupport {
 
     @Produce(uri = "direct:start")
     protected ProducerTemplate template;
-    
+
     @Override
     @Before
     public void setUp() throws Exception {
@@ -53,7 +54,7 @@ public class FopComponentTest extends CamelTestSupport {
         template.sendBody(inputStream);
         resultEndpoint.assertIsSatisfied();
 
-        PDDocument document = PDDocument.load("target/data/result.pdf");
+        PDDocument document = PDDocument.load(new File("target/data/result.pdf"));
         String pdfText = FopHelper.extractTextFrom(document);
         assertTrue(pdfText.contains("Project"));    //from xsl template
         assertTrue(pdfText.contains("John Doe"));   //from data xml
@@ -62,7 +63,7 @@ public class FopComponentTest extends CamelTestSupport {
         Exchange exchange = resultEndpoint.getReceivedExchanges().get(0);
         assertEquals("Header value is lost!", "bar", exchange.getIn().getHeader("foo"));
     }
-    
+
     @Override
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
diff --git a/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopEndpointTest.java
b/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopEndpointTest.java
index 884300b..9805fcc 100644
--- a/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopEndpointTest.java
+++ b/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopEndpointTest.java
@@ -80,12 +80,15 @@ public class FopEndpointTest extends CamelTestSupport {
         Endpoint endpoint = context().getEndpoint("fop:pdf");
         Producer producer = endpoint.createProducer();
         Exchange exchange = new DefaultExchange(context);
-        exchange.getIn().setHeader("CamelFop.Encrypt.userPassword", "secret");
+        final String password = "secret";
+        exchange.getIn().setHeader("CamelFop.Encrypt.userPassword", password);
         exchange.getIn().setBody(FopHelper.decorateTextWithXSLFO("Test Content"));
 
         producer.process(exchange);
-        PDDocument document = getDocumentFrom(exchange);
-        assertTrue(document.isEncrypted());
+        try (InputStream inputStream = exchange.getOut().getBody(InputStream.class)) {
+            PDDocument document = PDDocument.load(inputStream, password);
+            assertTrue(document.isEncrypted());
+        }
     }
 
     @Test
diff --git a/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopHelper.java
b/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopHelper.java
index fee920c..b016ec1 100644
--- a/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopHelper.java
+++ b/components/camel-fop/src/test/java/org/apache/camel/component/fop/FopHelper.java
@@ -21,29 +21,14 @@ import java.io.StringWriter;
 import java.io.Writer;
 
 import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.exceptions.CryptographyException;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDDocumentInformation;
-import org.apache.pdfbox.pdmodel.encryption.BadSecurityHandlerException;
-import org.apache.pdfbox.pdmodel.encryption.DecryptionMaterial;
-import org.apache.pdfbox.pdmodel.encryption.StandardDecryptionMaterial;
-import org.apache.pdfbox.util.PDFTextStripper;
+import org.apache.pdfbox.text.PDFTextStripper;
 
 public final class FopHelper {
     private FopHelper() {
     }
 
-    //decryption requires additional libraries
-    public static void decryptPDFN(PDDocument document, String password) throws
-            IOException, CryptographyException, BadSecurityHandlerException {
-        if (document.isEncrypted()) {
-            DecryptionMaterial decryptionMaterial = new StandardDecryptionMaterial(password);
-            document.openProtection(decryptionMaterial);
-        } else {
-            throw new RuntimeException("Document not encrypted");
-        }
-    }
-
     public static String extractTextFrom(PDDocument document) throws IOException {
         Writer output = new StringWriter();
         PDFTextStripper stripper = new PDFTextStripper();
@@ -53,7 +38,7 @@ public final class FopHelper {
 
     public static String getDocumentMetadataValue(PDDocument document, COSName name) {
         PDDocumentInformation info = document.getDocumentInformation();
-        return info.getDictionary().getString(name);
+        return info.getCOSObject().getString(name);
     }
 
     public static String decorateTextWithXSLFO(String text) {
diff --git a/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/PdfConfiguration.java
b/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/PdfConfiguration.java
index 066d801..a836540 100644
--- a/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/PdfConfiguration.java
+++ b/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/PdfConfiguration.java
@@ -45,14 +45,14 @@ public class PdfConfiguration {
     private static final Map<String, PDRectangle> PAGE_MAP = new HashMap<String,
PDRectangle>();
 
     static {
-        PAGE_MAP.put(PAGE_SIZE_A0, PDPage.PAGE_SIZE_A0);
-        PAGE_MAP.put(PAGE_SIZE_A1, PDPage.PAGE_SIZE_A1);
-        PAGE_MAP.put(PAGE_SIZE_A2, PDPage.PAGE_SIZE_A2);
-        PAGE_MAP.put(PAGE_SIZE_A3, PDPage.PAGE_SIZE_A3);
-        PAGE_MAP.put(PAGE_SIZE_A4, PDPage.PAGE_SIZE_A4);
-        PAGE_MAP.put(PAGE_SIZE_A5, PDPage.PAGE_SIZE_A5);
-        PAGE_MAP.put(PAGE_SIZE_A6, PDPage.PAGE_SIZE_A6);
-        PAGE_MAP.put(PAGE_SIZE_LETTER, PDPage.PAGE_SIZE_LETTER);
+        PAGE_MAP.put(PAGE_SIZE_A0, PDRectangle.A0);
+        PAGE_MAP.put(PAGE_SIZE_A1, PDRectangle.A1);
+        PAGE_MAP.put(PAGE_SIZE_A2, PDRectangle.A2);
+        PAGE_MAP.put(PAGE_SIZE_A3, PDRectangle.A3);
+        PAGE_MAP.put(PAGE_SIZE_A4, PDRectangle.A4);
+        PAGE_MAP.put(PAGE_SIZE_A5, PDRectangle.A5);
+        PAGE_MAP.put(PAGE_SIZE_A6, PDRectangle.A6);
+        PAGE_MAP.put(PAGE_SIZE_LETTER, PDRectangle.LETTER);
     }
 
     @UriPath(description = "Operation type")
@@ -69,7 +69,7 @@ public class PdfConfiguration {
     @UriParam(defaultValue = "14")
     private float fontSize = 14;
     @UriParam(defaultValue = "PAGE_SIZE_A4", enums = "PAGE_SIZE_A0,PAGE_SIZE_A1,PAGE_SIZE_A2,PAGE_SIZE_A3,PAGE_SIZE_A4,PAGE_SIZE_A5,PAGE_SIZE_A6,PAGE_SIZE_LETTER")
-    private PDRectangle pageSize = PDPage.PAGE_SIZE_A4;
+    private PDRectangle pageSize = PDRectangle.A4;
     @UriParam(defaultValue = "Helvetica")
     private PDFont font = PDType1Font.HELVETICA;
     @UriParam(defaultValue = "lineTermination")
@@ -169,7 +169,7 @@ public class PdfConfiguration {
     }
 
     public void setFont(String font) {
-        setFont(PDType1Font.getStandardFont(font));
+        setFont(Standard14Fonts.getByName(font));
     }
 
     public TextProcessingFactory getTextProcessingFactory() {
diff --git a/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/PdfProducer.java
b/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/PdfProducer.java
index be60aff..11b7313 100644
--- a/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/PdfProducer.java
+++ b/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/PdfProducer.java
@@ -29,15 +29,11 @@ import org.apache.camel.component.pdf.text.SplitStrategy;
 import org.apache.camel.component.pdf.text.TextProcessingAbstractFactory;
 import org.apache.camel.component.pdf.text.WriteStrategy;
 import org.apache.camel.impl.DefaultProducer;
-import org.apache.pdfbox.exceptions.COSVisitorException;
-import org.apache.pdfbox.exceptions.CryptographyException;
-import org.apache.pdfbox.exceptions.InvalidPasswordException;
 import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.pdmodel.encryption.BadSecurityHandlerException;
 import org.apache.pdfbox.pdmodel.encryption.DecryptionMaterial;
 import org.apache.pdfbox.pdmodel.encryption.ProtectionPolicy;
 import org.apache.pdfbox.pdmodel.encryption.StandardProtectionPolicy;
-import org.apache.pdfbox.util.PDFTextStripper;
+import org.apache.pdfbox.text.PDFTextStripper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -83,7 +79,7 @@ public class PdfProducer extends DefaultProducer {
         exchange.getOut().setBody(result);
     }
 
-    private Object doAppend(Exchange exchange) throws IOException, BadSecurityHandlerException,
CryptographyException, InvalidPasswordException, COSVisitorException {
+    private Object doAppend(Exchange exchange) throws IOException {
         LOG.debug("Got {} operation, going to append text to provided pdf.", pdfConfiguration.getOperation());
         String body = exchange.getIn().getBody(String.class);
         PDDocument document = exchange.getIn().getHeader(PDF_DOCUMENT_HEADER_NAME, PDDocument.class);
@@ -93,16 +89,6 @@ public class PdfProducer extends DefaultProducer {
         }
 
         if (document.isEncrypted()) {
-            DecryptionMaterial decryptionMaterial = exchange.getIn().getHeader(DECRYPTION_MATERIAL_HEADER_NAME,
-                    DecryptionMaterial.class);
-            if (decryptionMaterial == null) {
-                throw new IllegalArgumentException(String.format("%s header is expected for
%s operation "
-                                + "on encrypted document",
-                        DECRYPTION_MATERIAL_HEADER_NAME,
-                        pdfConfiguration.getOperation()));
-            }
-
-            document.openProtection(decryptionMaterial);
             document.setAllSecurityToBeRemoved(true);
         }
 
@@ -115,27 +101,16 @@ public class PdfProducer extends DefaultProducer {
         return byteArrayOutputStream;
     }
 
-    private String doExtractText(Exchange exchange) throws IOException, CryptographyException,
InvalidPasswordException, BadSecurityHandlerException {
+    private String doExtractText(Exchange exchange) throws IOException {
         LOG.debug("Got {} operation, going to extract text from provided pdf.", pdfConfiguration.getOperation());
         PDDocument document = exchange.getIn().getBody(PDDocument.class);
 
-        if (document.isEncrypted()) {
-            DecryptionMaterial decryptionMaterial = exchange.getIn().getHeader(DECRYPTION_MATERIAL_HEADER_NAME,
-                    DecryptionMaterial.class);
-            if (decryptionMaterial == null) {
-                throw new IllegalArgumentException(String.format("%s header is expected for
%s operation "
-                                + "on encrypted document",
-                        DECRYPTION_MATERIAL_HEADER_NAME,
-                        pdfConfiguration.getOperation()));
-            }
-            document.openProtection(decryptionMaterial);
-        }
 
         PDFTextStripper pdfTextStripper = new PDFTextStripper();
         return pdfTextStripper.getText(document);
     }
 
-    private OutputStream doCreate(Exchange exchange) throws IOException, BadSecurityHandlerException,
COSVisitorException {
+    private OutputStream doCreate(Exchange exchange) throws IOException {
         LOG.debug("Got {} operation, going to create and write provided string to pdf document.",
                 pdfConfiguration.getOperation());
         String body = exchange.getIn().getBody(String.class);
@@ -148,7 +123,7 @@ public class PdfProducer extends DefaultProducer {
         return byteArrayOutputStream;
     }
 
-    private void appendToPdfDocument(String text, PDDocument document, ProtectionPolicy protectionPolicy)
throws IOException, BadSecurityHandlerException {
+    private void appendToPdfDocument(String text, PDDocument document, ProtectionPolicy protectionPolicy)
throws IOException {
         Collection<String> words = splitStrategy.split(text);
         Collection<String> lines = lineBuilderStrategy.buildLines(words);
         writeStrategy.write(lines, document);
diff --git a/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/Standard14Fonts.java
b/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/Standard14Fonts.java
new file mode 100644
index 0000000..06c2f37
--- /dev/null
+++ b/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/Standard14Fonts.java
@@ -0,0 +1,59 @@
+/**
+ * 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.component.pdf;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.pdfbox.pdmodel.font.PDType1Font;
+
+/**
+ * The 14 standard fonts by name. Created here because there is no way to get a standard
font by name in {@code pdfbox} 2.0
+ *
+ * @author <a href="https://github.com/ppalaga">Peter Palaga</a>
+ */
+public class Standard14Fonts {
+    private static final Map<String, PDType1Font> FONTS_BY_NAME = new HashMap<>();
+    static
+    {
+        FONTS_BY_NAME.put(PDType1Font.TIMES_ROMAN.getBaseFont(), PDType1Font.TIMES_ROMAN);
+        FONTS_BY_NAME.put(PDType1Font.TIMES_BOLD.getBaseFont(), PDType1Font.TIMES_BOLD);
+        FONTS_BY_NAME.put(PDType1Font.TIMES_ITALIC.getBaseFont(), PDType1Font.TIMES_ITALIC);
+        FONTS_BY_NAME.put(PDType1Font.TIMES_BOLD_ITALIC.getBaseFont(), PDType1Font.TIMES_BOLD_ITALIC);
+        FONTS_BY_NAME.put(PDType1Font.HELVETICA.getBaseFont(), PDType1Font.HELVETICA);
+        FONTS_BY_NAME.put(PDType1Font.HELVETICA_BOLD.getBaseFont(), PDType1Font.HELVETICA_BOLD);
+        FONTS_BY_NAME.put(PDType1Font.HELVETICA_OBLIQUE.getBaseFont(), PDType1Font.HELVETICA_OBLIQUE);
+        FONTS_BY_NAME.put(PDType1Font.HELVETICA_BOLD_OBLIQUE.getBaseFont(), PDType1Font.HELVETICA_BOLD_OBLIQUE);
+        FONTS_BY_NAME.put(PDType1Font.COURIER.getBaseFont(), PDType1Font.COURIER);
+        FONTS_BY_NAME.put(PDType1Font.COURIER_BOLD.getBaseFont(), PDType1Font.COURIER_BOLD);
+        FONTS_BY_NAME.put(PDType1Font.COURIER_OBLIQUE.getBaseFont(), PDType1Font.COURIER_OBLIQUE);
+        FONTS_BY_NAME.put(PDType1Font.COURIER_BOLD_OBLIQUE.getBaseFont(), PDType1Font.COURIER_BOLD_OBLIQUE);
+        FONTS_BY_NAME.put(PDType1Font.SYMBOL.getBaseFont(), PDType1Font.SYMBOL);
+        FONTS_BY_NAME.put(PDType1Font.ZAPF_DINGBATS.getBaseFont(), PDType1Font.ZAPF_DINGBATS);
+    }
+
+    /**
+     * Get one of the 14 standard fonts by base font name.
+     *
+     * @param fontName the base font name, such as {@code "Helvetica"} or {@code "Helvetica-Bold"}
+     * @return the {@link PDType1Font} or null, of the {@code fontName} is not mapped to
any font
+     */
+    public static PDType1Font getByName(String fontName) {
+        return FONTS_BY_NAME.get(fontName);
+    }
+
+}
diff --git a/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/text/DefaultWriteStrategy.java
b/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/text/DefaultWriteStrategy.java
index 188d846..e5f3f7b 100644
--- a/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/text/DefaultWriteStrategy.java
+++ b/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/text/DefaultWriteStrategy.java
@@ -22,7 +22,7 @@ import java.util.Collection;
 import org.apache.camel.component.pdf.PdfConfiguration;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
-import org.apache.pdfbox.pdmodel.edit.PDPageContentStream;
+import org.apache.pdfbox.pdmodel.PDPageContentStream;
 
 /**
  * Writes given lines to PDF document. If document already contains some text then new text
will be appended
diff --git a/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/text/PdfUtils.java
b/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/text/PdfUtils.java
index cc910f4..2574f5d 100644
--- a/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/text/PdfUtils.java
+++ b/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/text/PdfUtils.java
@@ -26,11 +26,11 @@ public final class PdfUtils {
     private PdfUtils() { }
 
     public static float getAverageFontHeight(PDFont font, float fontSize) throws IOException
{
-        return font.getFontHeight("A".getBytes(), 0, 1) / PDF_PIXEL_SIZE * fontSize;
+        return font.getBoundingBox().getHeight() / PDF_PIXEL_SIZE * fontSize;
     }
 
     public static float getFontHeightForString(String str, PDFont font, float fontSize) throws
IOException {
-        return font.getFontHeight(str.getBytes(), 0, 1) / PDF_PIXEL_SIZE * fontSize;
+        return font.getBoundingBox().getHeight() / PDF_PIXEL_SIZE * fontSize;
     }
 
     public static float getFontWidth(String str, PDFont font, float fontSize) throws IOException
{
diff --git a/components/camel-pdf/src/test/java/org/apache/camel/component/pdf/PdfAppendTest.java
b/components/camel-pdf/src/test/java/org/apache/camel/component/pdf/PdfAppendTest.java
index 8269f96..4ca5c0c 100644
--- a/components/camel-pdf/src/test/java/org/apache/camel/component/pdf/PdfAppendTest.java
+++ b/components/camel-pdf/src/test/java/org/apache/camel/component/pdf/PdfAppendTest.java
@@ -30,12 +30,13 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
-import org.apache.pdfbox.pdmodel.edit.PDPageContentStream;
+import org.apache.pdfbox.pdmodel.PDPageContentStream;
+import org.apache.pdfbox.pdmodel.common.PDRectangle;
 import org.apache.pdfbox.pdmodel.encryption.AccessPermission;
 import org.apache.pdfbox.pdmodel.encryption.StandardDecryptionMaterial;
 import org.apache.pdfbox.pdmodel.encryption.StandardProtectionPolicy;
 import org.apache.pdfbox.pdmodel.font.PDType1Font;
-import org.apache.pdfbox.util.PDFTextStripper;
+import org.apache.pdfbox.text.PDFTextStripper;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -58,7 +59,7 @@ public class PdfAppendTest extends CamelTestSupport {
         final String originalText = "Test";
         final String textToAppend = "Append";
         PDDocument document = new PDDocument();
-        PDPage page = new PDPage(PDPage.PAGE_SIZE_A4);
+        PDPage page = new PDPage(PDRectangle.A4);
         document.addPage(page);
         PDPageContentStream contentStream = new PDPageContentStream(document, page);
         contentStream.setFont(PDType1Font.HELVETICA, 12);
@@ -98,7 +99,7 @@ public class PdfAppendTest extends CamelTestSupport {
         final String originalText = "Test";
         final String textToAppend = "Append";
         PDDocument document = new PDDocument();
-        PDPage page = new PDPage(PDPage.PAGE_SIZE_A4);
+        PDPage page = new PDPage(PDRectangle.A4);
         document.addPage(page);
         PDPageContentStream contentStream = new PDPageContentStream(document, page);
         contentStream.setFont(PDType1Font.HELVETICA, 12);
@@ -121,7 +122,7 @@ public class PdfAppendTest extends CamelTestSupport {
         document.save(output);
 
         // Encryption happens after saving.
-        PDDocument encryptedDocument = PDDocument.load(new ByteArrayInputStream(output.toByteArray()));
+        PDDocument encryptedDocument = PDDocument.load(new ByteArrayInputStream(output.toByteArray()),
userPass);
 
         Map<String, Object> headers = new HashMap<String, Object>();
         headers.put(PdfHeaderConstants.PDF_DOCUMENT_HEADER_NAME, encryptedDocument);
@@ -136,7 +137,7 @@ public class PdfAppendTest extends CamelTestSupport {
                 Object body = exchange.getIn().getBody();
                 assertThat(body, instanceOf(ByteArrayOutputStream.class));
                 try {
-                    PDDocument doc = PDDocument.load(new ByteArrayInputStream(((ByteArrayOutputStream)
body).toByteArray()));
+                    PDDocument doc = PDDocument.load(new ByteArrayInputStream(((ByteArrayOutputStream)
body).toByteArray()), userPass);
                     PDFTextStripper pdfTextStripper = new PDFTextStripper();
                     String text = pdfTextStripper.getText(doc);
                     assertEquals(2, doc.getNumberOfPages());
diff --git a/components/camel-pdf/src/test/java/org/apache/camel/component/pdf/PdfCreationTest.java
b/components/camel-pdf/src/test/java/org/apache/camel/component/pdf/PdfCreationTest.java
index c74e1fb..07093f5 100644
--- a/components/camel-pdf/src/test/java/org/apache/camel/component/pdf/PdfCreationTest.java
+++ b/components/camel-pdf/src/test/java/org/apache/camel/component/pdf/PdfCreationTest.java
@@ -29,7 +29,7 @@ import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.encryption.AccessPermission;
 import org.apache.pdfbox.pdmodel.encryption.StandardProtectionPolicy;
-import org.apache.pdfbox.util.PDFTextStripper;
+import org.apache.pdfbox.text.PDFTextStripper;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -93,9 +93,8 @@ public class PdfCreationTest extends CamelTestSupport {
                 Object body = exchange.getIn().getBody();
                 assertThat(body, instanceOf(ByteArrayOutputStream.class));
                 try {
-                    PDDocument doc = PDDocument.load(new ByteArrayInputStream(((ByteArrayOutputStream)
body).toByteArray()));
+                    PDDocument doc = PDDocument.load(new ByteArrayInputStream(((ByteArrayOutputStream)
body).toByteArray()), userPass);
                     assertTrue("Expected encrypted document", doc.isEncrypted());
-                    doc.decrypt(userPass);
                     assertFalse("Printing should not be permitted", doc.getCurrentAccessPermission().canPrint());
                     PDFTextStripper pdfTextStripper = new PDFTextStripper();
                     String text = pdfTextStripper.getText(doc);
diff --git a/components/camel-pdf/src/test/java/org/apache/camel/component/pdf/PdfTextExtractionTest.java
b/components/camel-pdf/src/test/java/org/apache/camel/component/pdf/PdfTextExtractionTest.java
index 6d93d8a..9cc7019 100644
--- a/components/camel-pdf/src/test/java/org/apache/camel/component/pdf/PdfTextExtractionTest.java
+++ b/components/camel-pdf/src/test/java/org/apache/camel/component/pdf/PdfTextExtractionTest.java
@@ -27,7 +27,8 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
-import org.apache.pdfbox.pdmodel.edit.PDPageContentStream;
+import org.apache.pdfbox.pdmodel.PDPageContentStream;
+import org.apache.pdfbox.pdmodel.common.PDRectangle;
 import org.apache.pdfbox.pdmodel.encryption.AccessPermission;
 import org.apache.pdfbox.pdmodel.encryption.StandardDecryptionMaterial;
 import org.apache.pdfbox.pdmodel.encryption.StandardProtectionPolicy;
@@ -46,7 +47,7 @@ public class PdfTextExtractionTest extends CamelTestSupport {
     public void testExtractText() throws Exception {
         final String expectedText = "Test string";
         PDDocument document = new PDDocument();
-        PDPage page = new PDPage(PDPage.PAGE_SIZE_A4);
+        PDPage page = new PDPage(PDRectangle.A4);
         document.addPage(page);
         PDPageContentStream contentStream = new PDPageContentStream(document, page);
         contentStream.setFont(PDType1Font.HELVETICA, 12);
@@ -82,7 +83,7 @@ public class PdfTextExtractionTest extends CamelTestSupport {
         PDDocument document = new PDDocument();
 
         final String expectedText = "Test string";
-        PDPage page = new PDPage(PDPage.PAGE_SIZE_A4);
+        PDPage page = new PDPage(PDRectangle.A4);
         document.addPage(page);
         PDPageContentStream contentStream = new PDPageContentStream(document, page);
         contentStream.setFont(PDType1Font.HELVETICA, 12);
@@ -98,7 +99,7 @@ public class PdfTextExtractionTest extends CamelTestSupport {
         document.save(output);
 
         // Encryption happens after saving.
-        PDDocument encryptedDocument = PDDocument.load(new ByteArrayInputStream(output.toByteArray()));
+        PDDocument encryptedDocument = PDDocument.load(new ByteArrayInputStream(output.toByteArray()),
userPass);
 
         template.sendBodyAndHeader("direct:start",
                 encryptedDocument,
diff --git a/parent/pom.xml b/parent/pom.xml
index 7c5878b..61b5de8 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -558,7 +558,8 @@
     <pax-exam-version>4.9.2</pax-exam-version>
     <pax-tiny-bundle-version>1.3.2</pax-tiny-bundle-version>
     <pax-logging-version>1.8.6</pax-logging-version>
-    <pdfbox-version>1.8.13</pdfbox-version>
+    <pdfbox18-version>1.8.13</pdfbox18-version>
+    <pdfbox-version>2.0.6</pdfbox-version>
     <pgjdbc-ng-driver-version>0.7.1</pgjdbc-ng-driver-version>
     <protobuf-version>3.3.0</protobuf-version>
     <protobuf-guava-version>20.0</protobuf-guava-version>
@@ -4717,6 +4718,34 @@
         <version>${maven-archetype-packaging-version}</version>
       </dependency>
 
+
+      <!-- pdfbox -->
+      <dependency>
+        <groupId>org.apache.pdfbox</groupId>
+        <artifactId>jempbox</artifactId>
+        <version>${pdfbox18-version}</version><!-- because of Tika -->
+      </dependency>
+      <dependency>
+        <groupId>org.apache.pdfbox</groupId>
+        <artifactId>fontbox</artifactId>
+        <version>${pdfbox-version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.pdfbox</groupId>
+        <artifactId>pdfbox</artifactId>
+        <version>${pdfbox-version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.pdfbox</groupId>
+        <artifactId>pdfbox-tools</artifactId>
+        <version>${pdfbox-version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.pdfbox</groupId>
+        <artifactId>pdfbox-debugger</artifactId>
+        <version>${pdfbox-version}</version>
+      </dependency>
+
     </dependencies>
   </dependencyManagement>
 
diff --git a/platforms/karaf/features/src/main/resources/features.xml b/platforms/karaf/features/src/main/resources/features.xml
index 6cbdbba6..b14d60e 100644
--- a/platforms/karaf/features/src/main/resources/features.xml
+++ b/platforms/karaf/features/src/main/resources/features.xml
@@ -351,7 +351,7 @@
     <bundle dependency='true'>mvn:net.openhft/chronicle-map/${chronicle-map-version}</bundle>
     <bundle dependency='true'>mvn:net.openhft/chronicle-queue/${chronicle-queue-version}</bundle>
     <bundle dependency='true'>mvn:net.openhft/chronicle-engine/${chronicle-engine-version}</bundle>
-    <bundle dependency='true'>mvn:net.openhft/compiler/${openhft-compiler-version}</bundle>
   
+    <bundle dependency='true'>mvn:net.openhft/compiler/${openhft-compiler-version}</bundle>
     <bundle>mvn:org.apache.camel/camel-chronicle/${project.version}</bundle>
   </feature>
   <feature name='camel-chunk' version='${project.version}' resolver='(obr)' start-level='50'>
@@ -837,7 +837,7 @@
     <bundle dependency='true'>wrap:mvn:com.auth0/java-jwt/${grpc-java-jwt-version}</bundle>
     <bundle dependency='true'>wrap:mvn:com.google.auth/google-auth-library-oauth2-http/${grpc-google-auth-library-version}</bundle>
     <bundle dependency='true'>wrap:mvn:com.google.auth/google-auth-library-credentials/${grpc-google-auth-library-version}</bundle>
-    <bundle>mvn:org.apache.camel/camel-grpc/${project.version}</bundle>    
+    <bundle>mvn:org.apache.camel/camel-grpc/${project.version}</bundle>
   </feature>
   <feature name='camel-gson' version='${project.version}' resolver='(obr)' start-level='50'>
     <feature version='${project.version}'>camel-core</feature>
@@ -1707,7 +1707,6 @@
     <bundle dependency='true'>mvn:org.bouncycastle/bcpkix-jdk15on/${bouncycastle-version}</bundle>
     <bundle dependency='true'>mvn:org.apache.pdfbox/pdfbox/${pdfbox-version}</bundle>
     <bundle dependency='true'>mvn:org.apache.pdfbox/fontbox/${pdfbox-version}</bundle>
-    <bundle dependency='true'>mvn:org.apache.pdfbox/jempbox/${pdfbox-version}</bundle>
     <bundle>mvn:org.apache.camel/camel-pdf/${project.version}</bundle>
   </feature>
   <feature name='camel-pgevent' version='${project.version}' resolver='(obr)' start-level='50'>
diff --git a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
index dca4625..8cac9af 100644
--- a/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
+++ b/platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
@@ -3180,6 +3180,31 @@
         <version>2.4.2</version>
       </dependency>
       <dependency>
+        <groupId>org.apache.pdfbox</groupId>
+        <artifactId>fontbox</artifactId>
+        <version>2.0.6</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.pdfbox</groupId>
+        <artifactId>jempbox</artifactId>
+        <version>1.8.13</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.pdfbox</groupId>
+        <artifactId>pdfbox</artifactId>
+        <version>2.0.6</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.pdfbox</groupId>
+        <artifactId>pdfbox-debugger</artifactId>
+        <version>2.0.6</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.pdfbox</groupId>
+        <artifactId>pdfbox-tools</artifactId>
+        <version>2.0.6</version>
+      </dependency>
+      <dependency>
         <groupId>org.apache.ws.commons.axiom</groupId>
         <artifactId>axiom-api</artifactId>
         <version>1.2.14</version>

-- 
To stop receiving notification emails like this one, please contact
['"commits@camel.apache.org" <commits@camel.apache.org>'].

Mime
View raw message