Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Can we use PDF library with AEM 6.5.18

Avatar

Level 4

Hi all,

I'm trying to use Apache PDFBox for a workflow step (version 3.0.1) and the maven build runs in my local. However I see that my bundle fails to install and the org.apache.pdfbox cannot resolve in the AEM author.

 

stiegjo22_0-1707839998983.png

 

1 Accepted Solution

Avatar

Correct answer by
Level 4

To get this working, I used version 5.5.13 of IText Core on our AEM author and included it in both my parent pom and core pom.

 

            <!-- iTextPDF -->
            <dependency>
                <groupId>com.itextpdf</groupId>
                <artifactId>itextpdf</artifactId>
                <version>5.5.13</version>
            </dependency>

 

 

https://mvnrepository.com/artifact/com.itextpdf/itextpdf/5.5.13.3

View solution in original post

13 Replies

Avatar

Community Advisor

can you please provide you pom.xml entry for pdfbox

 

<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>3.0.1</version>
<scope>compile</scope>
</dependency>

 

 

or you can try embed explicitly to the maven-bundle-plugin

 

<Embed-Dependency>
pdfbox;scope=compile|runtime
</Embed-Dependency>

Avatar

Level 4

Here's my entry for pdfbox in the pom:

            <!-- Apache PDF Box -->
            <dependency>
                <groupId>org.apache.pdfbox</groupId>
                <artifactId>pdfbox</artifactId>
                <version>3.0.1</version>
                <scope>compile</scope>
            </dependency>

 

Avatar

Community Advisor

Hi @stiegjo22 

 

AEM works with very lower versions of PDFBOX only. Might be this the limitation while you are working in AEM, so keep these things in mind.

 

Avatar

Level 4

I went down to version 2.0.9 and it still failed. Does anyone know what is the lowest version that works with AEM? Thanks.

Avatar

Level 4

I tried with lower versions of PDFBOX - 1.8.0 and 1.6.0. Both show the same error message after running a maven build and deploying to AEM author 6.5.18.

Avatar

Community Advisor

Do you see pdfbox as part of your /system/cobsole/bundles...

if not, can you please download jar and try uploading one manually just for quick verification or download in local have this as part of code and upload as external jar through code.

Avatar

Community Advisor

Hi @stiegjo22 
Please check the correct dependency using dependency finder.

http://localhost:4502/system/console/depfinder

 

If dependency does not exists then you need to installed the pdfbox bundle in AEM, using embedded; Example

 

Also In your POM you added dependency scope as compile, thats means dependency will only be available for compile time.



Arun Patidar

Avatar

Level 4

 

 

Now I'm trying to use a different PDF library - https://mvnrepository.com/artifact/com.itextpdf/kernel

I've added the Maven Bundle Plugin to my project's pom.xml file and specified instructions such as Export-Package.

 

 

     <!-- Maven Bundle Plugin -->
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>4.1.0</version>
                <extensions>true</extensions>
       <configuration>
                    <instructions>
                        <Import-Package>
                            com.itextpdf.kernel.*;version="[8.0,9)",
                            com.itextpdf.io.*;version="[8.0,9)", *
                        </Import-Package>
                        <Export-Package>
                            com.itextpdf.bundle;version="1.0.0"
                        </Export-Package>
                        <Embed-Dependency>
                            itext.kernel;version="[8.0,9)",scope=compile|runtime
                        </Embed-Dependency>
                        <Embed-Transitive>true</Embed-Transitive>
                        <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
                        <Bundle-Version>${project.version}</Bundle-Version>
                    </instructions>
                </configuration>
            </plugin>

 

 

However I can't find the com.itextpdf.bundle in the 'Target" directory after running maven clean install.

Avatar

Community Advisor

did you add itextpdf kernel dependency ?

 

<!-- iText PDF library -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>kernel</artifactId>
<version>7.1.15</version> --- Check the version correct or not
</dependency>

Avatar

Level 4
          <!-- iText Kernal -->
            <dependency>
                <groupId>com.itextpdf</groupId>
                <artifactId>kernel</artifactId>
                <version>8.0.3</version>
            </dependency>

Avatar

Community Advisor

is it downloading the dependencies ?

try (force) mvn clean install 

check your .m2 folder for the libraries (settings.xml)

Avatar

Correct answer by
Level 4

To get this working, I used version 5.5.13 of IText Core on our AEM author and included it in both my parent pom and core pom.

 

            <!-- iTextPDF -->
            <dependency>
                <groupId>com.itextpdf</groupId>
                <artifactId>itextpdf</artifactId>
                <version>5.5.13</version>
            </dependency>

 

 

https://mvnrepository.com/artifact/com.itextpdf/itextpdf/5.5.13.3