Can we use PDF library with AEM 6.5.18 | Community
Skip to main content
stiegjo22
Level 4
February 13, 2024
Solved

Can we use PDF library with AEM 6.5.18

  • February 13, 2024
  • 5 replies
  • 3568 views

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.

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by stiegjo22

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

5 replies

SureshDhulipudi
Community Advisor
Community Advisor
February 13, 2024

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>

stiegjo22
stiegjo22Author
Level 4
February 13, 2024

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>

 

Jagadeesh_Prakash
Community Advisor
Community Advisor
February 13, 2024

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.

 

stiegjo22
stiegjo22Author
Level 4
February 13, 2024

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.

SureshDhulipudi
Community Advisor
Community Advisor
February 13, 2024
Imran__Khan
Community Advisor
Community Advisor
February 13, 2024

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.

arunpatidar
Community Advisor
Community Advisor
February 14, 2024

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
stiegjo22
stiegjo22Author
Level 4
February 14, 2024

 

 

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.

SureshDhulipudi
Community Advisor
Community Advisor
February 14, 2024

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>
stiegjo22
stiegjo22AuthorAccepted solution
Level 4
February 14, 2024

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