manuelbl / SwissQRBill

Java library for Swiss QR bill payment slips (aka QR-Rechnung)
https://www.codecrete.net/qrbill
MIT License
156 stars 37 forks source link

issue with latest pdfbox dependency (PDDocument.load) #42

Closed gesteur closed 2 years ago

gesteur commented 2 years ago

Hi Manuel,

I have updated the QRbill to your latest version (was working very good in the past) and now i m facing some issues with the pdfbox dependency. it seems pdfbox version 3.0.0 doenst have the load method anymore. This method is called when I use your library with the following statement PDFCanvas canvas = new PDFCanvas(file, PDFCanvas.LAST_PAGE) which calls the PDDocument.load(pdfDocument) method.

which results in the following crash. java.lang.NoSuchMethodError: org.apache.pdfbox.pdmodel.PDDocument.load([B)Lorg/apache/pdfbox/pdmodel/PDDocument;

I managed to fix this in restricting the pdfbox dependency to 2.0.23 in qrbill-generator-2.5.3.pom

`org.apache.pdfbox

pdfbox
  <version>[2.0.23]</version>
  <scope>runtime</scope>

`

manuelbl commented 2 years ago

This exact issue was fixed in version 2.5.1 with the expression [2.0.0,3.0).

It is still present in in version 2.5.3 (see https://github.com/manuelbl/SwissQRBill/blob/v2.5.3/generator/build.gradle#L142 and https://repo1.maven.org/maven2/net/codecrete/qrbill/qrbill-generator/2.5.3/qrbill-generator-2.5.3.pom).

What is your exact setup? What build tool and what programming language are you using?

gesteur commented 2 years ago

yes that expression doesnt work, it downloads also pdfbox version 3.0 and seems to cause issues no?

i'm using maven and java 11. downloading your repo and doing ./mvnw install or also running in eclipse, both ways, i get the error when the PDDocument.load method is called.

manuelbl commented 2 years ago

It turns out that the expression [2.0.0,3.0) does what one would expect when using Gradle, but does something different when using Maven. I will fix it with the next release.

Until then, it's probably better to add the below dependency to your POM file to set the PDFBox version instead of modifying qrbill-generator-2.5.3.pom:

<dependency>
  <groupId>org.apache.pdfbox</groupId>
  <artifactId>pdfbox</artifactId>
  <version>2.0.24</version>
  <scope>runtime</scope>
</dependency>
manuelbl commented 2 years ago

I've fixed it with version 2.5.4, which should be available in Maven Central in a few hours.