You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2023/08/29 06:19:25 UTC

[camel] branch pdfbox-3.x created (now 9a0b4af9aea)

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

acosentino pushed a change to branch pdfbox-3.x
in repository https://gitbox.apache.org/repos/asf/camel.git


      at 9a0b4af9aea CAMEL-19796 - camel-pdf - Upgrade to pdfbox 3.x

This branch includes the following new commits:

     new 9a0b4af9aea CAMEL-19796 - camel-pdf - Upgrade to pdfbox 3.x

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[camel] 01/01: CAMEL-19796 - camel-pdf - Upgrade to pdfbox 3.x

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch pdfbox-3.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 9a0b4af9aea3d8f6265052201b5b9798683a6403
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Aug 29 08:17:46 2023 +0200

    CAMEL-19796 - camel-pdf - Upgrade to pdfbox 3.x
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../org/apache/camel/component/pdf/pdf.json        |  2 +-
 .../camel/component/pdf/PdfConfiguration.java      | 15 +++---
 .../camel/component/pdf/Standard14Fonts.java       | 60 ----------------------
 .../pdf/text/DefaultLineBuilderStrategy.java       |  4 +-
 .../component/pdf/text/DefaultWriteStrategy.java   | 10 ++--
 .../apache/camel/component/pdf/PdfAppendTest.java  | 16 ++++--
 .../camel/component/pdf/PdfCreationTest.java       | 10 ++--
 .../camel/component/pdf/PdfTextExtractionTest.java | 10 ++--
 .../ROOT/pages/camel-4x-upgrade-guide-4_1.adoc     |  6 +++
 parent/pom.xml                                     |  2 +-
 10 files changed, 50 insertions(+), 85 deletions(-)

diff --git a/components/camel-pdf/src/generated/resources/org/apache/camel/component/pdf/pdf.json b/components/camel-pdf/src/generated/resources/org/apache/camel/component/pdf/pdf.json
index 0ba759ba3b5..18499dbc195 100644
--- a/components/camel-pdf/src/generated/resources/org/apache/camel/component/pdf/pdf.json
+++ b/components/camel-pdf/src/generated/resources/org/apache/camel/component/pdf/pdf.json
@@ -32,7 +32,7 @@
   },
   "properties": {
     "operation": { "index": 0, "kind": "path", "displayName": "Operation", "group": "producer", "label": "", "required": true, "type": "object", "javaType": "org.apache.camel.component.pdf.PdfOperation", "enum": [ "create", "append", "extractText" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.pdf.PdfConfiguration", "configurationField": "pdfConfiguration", "description": "Operation type" },
-    "font": { "index": 1, "kind": "parameter", "displayName": "Font", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "enum": [ "Courier", "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique", "Helvetica", "Helvetica-Bold", "Helvetica-Oblique", "Helvetica-BoldOblique", "Times-Roman", "Times-Bold", "Times-Italic", "Times-BoldItalic", "Symbol", "ZapfDingbats" ], "deprecated": false, "autowired": false, "secret": false, "defaultValu [...]
+    "font": { "index": 1, "kind": "parameter", "displayName": "Font", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "enum": [ "COURIER", "COURIER_BOLD", "COURIER_OBLIQUE", "COURIER_BOLD_OBLIQUE", "HELVETICA", "HELVETICA_BOLD", "HELVETICA_OBLIQUE", "HELVETICA_BOLD_OBLIQUE", "TIMES_ROMAN", "TIMES_BOLD", "TIMES_ITALIC", "TIMES_BOLD_ITALIC", "SYMBOL", "ZAPF_DINGBATS" ], "deprecated": false, "autowired": false, "secret": false, "default [...]
     "fontSize": { "index": 2, "kind": "parameter", "displayName": "Font Size", "group": "producer", "label": "", "required": false, "type": "number", "javaType": "float", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 14.0, "configurationClass": "org.apache.camel.component.pdf.PdfConfiguration", "configurationField": "pdfConfiguration", "description": "Font size in pixels" },
     "marginBottom": { "index": 3, "kind": "parameter", "displayName": "Margin Bottom", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 20, "configurationClass": "org.apache.camel.component.pdf.PdfConfiguration", "configurationField": "pdfConfiguration", "description": "Margin bottom in pixels" },
     "marginLeft": { "index": 4, "kind": "parameter", "displayName": "Margin Left", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 20, "configurationClass": "org.apache.camel.component.pdf.PdfConfiguration", "configurationField": "pdfConfiguration", "description": "Margin left in pixels" },
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 e3f72d6dc89..82237ea3114 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
@@ -24,7 +24,6 @@ import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
 import org.apache.camel.spi.UriPath;
 import org.apache.pdfbox.pdmodel.common.PDRectangle;
-import org.apache.pdfbox.pdmodel.font.PDFont;
 
 import static org.apache.camel.component.pdf.PdfPageSizeConstant.PAGE_SIZE_A0;
 import static org.apache.camel.component.pdf.PdfPageSizeConstant.PAGE_SIZE_A1;
@@ -68,11 +67,11 @@ public class PdfConfiguration {
     private float fontSize = 14;
     @UriParam(defaultValue = "A4", enums = "LETTER,LEGAL,A0,A1,A2,A3,A4,A5,A6")
     private String pageSize = PAGE_SIZE_A4;
-    @UriParam(defaultValue = "Helvetica", enums = "Courier,Courier-Bold,Courier-Oblique,Courier-BoldOblique,"
-                                                  + "Helvetica,Helvetica-Bold,Helvetica-Oblique,Helvetica-BoldOblique,"
-                                                  + "Times-Roman,Times-Bold,Times-Italic,Times-BoldItalic,"
-                                                  + "Symbol,ZapfDingbats")
-    private String font = "Helvetica";
+    @UriParam(defaultValue = "HELVETICA", enums = "COURIER,COURIER_BOLD,COURIER_OBLIQUE,COURIER_BOLD_OBLIQUE,"
+                                                  + "HELVETICA,HELVETICA_BOLD,HELVETICA_OBLIQUE,HELVETICA_BOLD_OBLIQUE,"
+                                                  + "TIMES_ROMAN,TIMES_BOLD,TIMES_ITALIC,TIMES_BOLD_ITALIC,"
+                                                  + "SYMBOL,ZAPF_DINGBATS")
+    private String font = "HELVETICA";
     @UriParam(defaultValue = "lineTermination")
     private TextProcessingFactory textProcessingFactory = TextProcessingFactory.lineTermination;
 
@@ -154,8 +153,8 @@ public class PdfConfiguration {
         this.pageSize = pageSize;
     }
 
-    public PDFont getFont() {
-        return Standard14Fonts.getByName(font);
+    public String getFont() {
+        return font;
     }
 
     /**
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
deleted file mode 100644
index acc564175a8..00000000000
--- a/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/Standard14Fonts.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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
- */
-public final 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);
-    }
-
-    private Standard14Fonts() {
-    }
-
-    /**
-     * 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/DefaultLineBuilderStrategy.java b/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/text/DefaultLineBuilderStrategy.java
index 9c810ba10d6..5d39efe82da 100644
--- a/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/text/DefaultLineBuilderStrategy.java
+++ b/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/text/DefaultLineBuilderStrategy.java
@@ -23,6 +23,8 @@ import java.util.LinkedList;
 
 import org.apache.camel.component.pdf.PdfConfiguration;
 import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.pdfbox.pdmodel.font.PDType1Font;
+import org.apache.pdfbox.pdmodel.font.Standard14Fonts;
 
 import static org.apache.camel.component.pdf.PdfConstants.MIN_CONTENT_WIDTH;
 
@@ -106,7 +108,7 @@ public class DefaultLineBuilderStrategy implements LineBuilderStrategy {
     private boolean isLineFitInLineWidth(String currentLine, float allowedLineWidth) throws IOException {
         float fontWidth = PdfUtils.getFontWidth(
                 currentLine,
-                pdfConfiguration.getFont(),
+                new PDType1Font(Standard14Fonts.FontName.valueOf(pdfConfiguration.getFont())),
                 pdfConfiguration.getFontSize());
 
         return fontWidth <= allowedLineWidth;
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 5613126f706..3dd7639024b 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
@@ -23,6 +23,8 @@ import org.apache.camel.component.pdf.PdfConfiguration;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.PDPageContentStream;
+import org.apache.pdfbox.pdmodel.font.PDType1Font;
+import org.apache.pdfbox.pdmodel.font.Standard14Fonts;
 
 /**
  * Writes given lines to PDF document. If document already contains some text then new text will be appended to new
@@ -42,8 +44,9 @@ public class DefaultWriteStrategy implements WriteStrategy {
         document.addPage(page);
         float x = pdfConfiguration.getMarginLeft();
         float y = page.getMediaBox().getHeight() - pdfConfiguration.getMarginTop();
-        float averageFontHeight = PdfUtils.getAverageFontHeight(pdfConfiguration.getFont(),
-                pdfConfiguration.getFontSize());
+        float averageFontHeight
+                = PdfUtils.getAverageFontHeight(new PDType1Font(Standard14Fonts.FontName.valueOf(pdfConfiguration.getFont())),
+                        pdfConfiguration.getFontSize());
         float lineSpacing = averageFontHeight * 2;
 
         PDPageContentStream contentStream = initializeContentStream(document, page);
@@ -75,7 +78,8 @@ public class DefaultWriteStrategy implements WriteStrategy {
 
     private PDPageContentStream initializeContentStream(PDDocument document, PDPage page) throws IOException {
         PDPageContentStream contentStream = new PDPageContentStream(document, page);
-        contentStream.setFont(pdfConfiguration.getFont(), pdfConfiguration.getFontSize());
+        contentStream.setFont(new PDType1Font(Standard14Fonts.FontName.valueOf(pdfConfiguration.getFont())),
+                pdfConfiguration.getFontSize());
         return contentStream;
     }
 }
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 425007565b3..612631ae9aa 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
@@ -29,6 +29,8 @@ import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit5.CamelTestSupport;
+import org.apache.pdfbox.Loader;
+import org.apache.pdfbox.io.RandomAccessReadBuffer;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.PDPageContentStream;
@@ -37,6 +39,7 @@ 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.pdmodel.font.Standard14Fonts;
 import org.apache.pdfbox.text.PDFTextStripper;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -65,7 +68,7 @@ public class PdfAppendTest extends CamelTestSupport {
         PDPage page = new PDPage(PDRectangle.A4);
         document.addPage(page);
         PDPageContentStream contentStream = new PDPageContentStream(document, page);
-        contentStream.setFont(PDType1Font.HELVETICA, 12);
+        contentStream.setFont(new PDType1Font(Standard14Fonts.FontName.HELVETICA), 12);
         contentStream.beginText();
         contentStream.newLineAtOffset(20, 400);
         contentStream.showText(originalText);
@@ -81,7 +84,8 @@ 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 = Loader.loadPDF(
+                            new RandomAccessReadBuffer(new ByteArrayInputStream(((ByteArrayOutputStream) body).toByteArray())));
                     PDFTextStripper pdfTextStripper = new PDFTextStripper();
                     String text = pdfTextStripper.getText(doc);
                     assertEquals(2, doc.getNumberOfPages());
@@ -105,7 +109,7 @@ public class PdfAppendTest extends CamelTestSupport {
         PDPage page = new PDPage(PDRectangle.A4);
         document.addPage(page);
         PDPageContentStream contentStream = new PDPageContentStream(document, page);
-        contentStream.setFont(PDType1Font.HELVETICA, 12);
+        contentStream.setFont(new PDType1Font(Standard14Fonts.FontName.HELVETICA), 12);
         contentStream.beginText();
         contentStream.newLineAtOffset(20, 400);
         contentStream.showText(originalText);
@@ -125,7 +129,8 @@ public class PdfAppendTest extends CamelTestSupport {
         document.save(output);
 
         // Encryption happens after saving.
-        PDDocument encryptedDocument = PDDocument.load(new ByteArrayInputStream(output.toByteArray()), userPass);
+        PDDocument encryptedDocument
+                = Loader.loadPDF(new RandomAccessReadBuffer(new ByteArrayInputStream(output.toByteArray())), userPass);
 
         Map<String, Object> headers = new HashMap<>();
         headers.put(PdfHeaderConstants.PDF_DOCUMENT_HEADER_NAME, encryptedDocument);
@@ -141,7 +146,8 @@ public class PdfAppendTest extends CamelTestSupport {
                 assertThat(body, instanceOf(ByteArrayOutputStream.class));
                 try {
                     PDDocument doc
-                            = PDDocument.load(new ByteArrayInputStream(((ByteArrayOutputStream) body).toByteArray()), userPass);
+                            = Loader.loadPDF(new RandomAccessReadBuffer(
+                                    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 ff598989ccf..efcd87c3674 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
@@ -27,6 +27,8 @@ import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit5.CamelTestSupport;
+import org.apache.pdfbox.Loader;
+import org.apache.pdfbox.io.RandomAccessReadBuffer;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.encryption.AccessPermission;
 import org.apache.pdfbox.pdmodel.encryption.StandardProtectionPolicy;
@@ -63,7 +65,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 = Loader.loadPDF(
+                            new RandomAccessReadBuffer(new ByteArrayInputStream(((ByteArrayOutputStream) body).toByteArray())));
                     PDFTextStripper pdfTextStripper = new PDFTextStripper();
                     String text = pdfTextStripper.getText(doc);
                     assertEquals(1, doc.getNumberOfPages());
@@ -99,7 +102,8 @@ public class PdfCreationTest extends CamelTestSupport {
                 assertThat(body, instanceOf(ByteArrayOutputStream.class));
                 try {
                     PDDocument doc
-                            = PDDocument.load(new ByteArrayInputStream(((ByteArrayOutputStream) body).toByteArray()), userPass);
+                            = Loader.loadPDF(new RandomAccessReadBuffer(
+                                    new ByteArrayInputStream(((ByteArrayOutputStream) body).toByteArray())), userPass);
                     assertTrue(doc.isEncrypted(), "Expected encrypted document");
                     assertFalse(doc.getCurrentAccessPermission().canPrint(), "Printing should not be permitted");
                     PDFTextStripper pdfTextStripper = new PDFTextStripper();
@@ -121,7 +125,7 @@ public class PdfCreationTest extends CamelTestSupport {
             @Override
             public void configure() {
                 from("direct:start")
-                        .to("pdf:create?fontSize=6&font=Courier&pageSize=PAGE_SIZE_A1")
+                        .to("pdf:create?fontSize=6&font=COURIER&pageSize=PAGE_SIZE_A1")
                         .to("mock:result");
             }
         };
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 3cca2bf5824..e49900da615 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
@@ -25,6 +25,8 @@ import org.apache.camel.Predicate;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit5.CamelTestSupport;
+import org.apache.pdfbox.Loader;
+import org.apache.pdfbox.io.RandomAccessReadBuffer;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.PDPageContentStream;
@@ -33,6 +35,7 @@ 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.pdmodel.font.Standard14Fonts;
 import org.junit.jupiter.api.Test;
 
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -51,7 +54,7 @@ public class PdfTextExtractionTest extends CamelTestSupport {
         PDPage page = new PDPage(PDRectangle.A4);
         document.addPage(page);
         PDPageContentStream contentStream = new PDPageContentStream(document, page);
-        contentStream.setFont(PDType1Font.HELVETICA, 12);
+        contentStream.setFont(new PDType1Font(Standard14Fonts.FontName.HELVETICA), 12);
         contentStream.beginText();
         contentStream.newLineAtOffset(20, 400);
         contentStream.showText(expectedText);
@@ -87,7 +90,7 @@ public class PdfTextExtractionTest extends CamelTestSupport {
         PDPage page = new PDPage(PDRectangle.A4);
         document.addPage(page);
         PDPageContentStream contentStream = new PDPageContentStream(document, page);
-        contentStream.setFont(PDType1Font.HELVETICA, 12);
+        contentStream.setFont(new PDType1Font(Standard14Fonts.FontName.HELVETICA), 12);
         contentStream.beginText();
         contentStream.newLineAtOffset(20, 400);
         contentStream.showText(expectedText);
@@ -100,7 +103,8 @@ public class PdfTextExtractionTest extends CamelTestSupport {
         document.save(output);
 
         // Encryption happens after saving.
-        PDDocument encryptedDocument = PDDocument.load(new ByteArrayInputStream(output.toByteArray()), userPass);
+        PDDocument encryptedDocument
+                = Loader.loadPDF(new RandomAccessReadBuffer(new ByteArrayInputStream(output.toByteArray())), userPass);
 
         template.sendBodyAndHeader("direct:start",
                 encryptedDocument,
diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_1.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_1.adoc
index ab28a6834b1..e4d2b6eae8f 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_1.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_1.adoc
@@ -93,3 +93,9 @@ Should be changed to
 from("direct:start")
   .to("aws2-sns://mytopic?subject=mySubject&autoCreateTopic=true&subscribeSNStoSQS=true&queueArn=arn:aws:sqs:xxxxx")
 ----
+
+=== camel-pdf
+
+The Camel-PDF component has been updated to Apache PDFBox 3.0.0 and the font parameter is now defined through the following enum values: COURIER,COURIER_BOLD,COURIER_OBLIQUE,COURIER_BOLD_OBLIQUE, HELVETICA,HELVETICA_BOLD,HELVETICA_OBLIQUE,HELVETICA_BOLD_OBLIQUE,TIMES_ROMAN,TIMES_BOLD,TIMES_ITALIC,TIMES_BOLD_ITALIC,SYMBOL and ZAPF_DINGBATS
+
+
diff --git a/parent/pom.xml b/parent/pom.xml
index fd501fb6b5f..6b7a787cdbe 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -375,7 +375,7 @@
         <paho-version>1.2.5</paho-version>
         <parquet-common-version>1.13.1</parquet-common-version>
         <parquet-avro-version>1.13.1</parquet-avro-version>
-        <pdfbox-version>2.0.29</pdfbox-version>
+        <pdfbox-version>3.0.0</pdfbox-version>
         <pgjdbc-driver-version>42.6.0</pgjdbc-driver-version>
         <pgjdbc-ng-driver-version>0.8.9</pgjdbc-ng-driver-version>
         <picocli-version>4.7.4</picocli-version>