Skip to content

Commit

Permalink
Compatbility with PDFBox 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelbl committed Nov 11, 2023
1 parent c0dd394 commit 0f221a7
Show file tree
Hide file tree
Showing 19 changed files with 308 additions and 222 deletions.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This library implements version 2.1 of the *Swiss Implementation Guidelines QR-b

## Introduction

The Swiss QR bill is the new QR code based payment format that started on 30 June, 2020. The old payment slip will no longer be accepted after 30 September 2022.
The Swiss QR bill is the new QR code based payment format that started on 30 June, 2020. The old payment slip is no longer accepted.

The new payment slip will be sent electronically in most cases. But it can still be printed at the bottom of an invoice or added to the invoice on a separate sheet. The payer scans the QR code with his/her mobile banking app to initiate the payment. The payment just needs to be confirmed.

Expand Down Expand Up @@ -132,6 +132,25 @@ To generate a QR bill, you first fill in the `Bill` data structure and then call

More information can be found in the [Wiki](https://github.com/manuelbl/SwissQRBill/wiki). It's the joint Wiki for the .NET and the Java version.

## PDF generation with Apache PDFBox

For generating QR bills as PDF, [Apache PDFBox](https://pdfbox.apache.org/) is used. This library is built and tested with version 2 of PDFBox. While this is still the most popular version in use, version 3.0 has been released. It is a major version and includes breaking changes.

This library is compatible with both versions. It uses reflection to deal with incompatible differences.

If you want to use version 3 instead of the default version 2, you need to add the following explicit dependency to your project (for Maven):

```xml
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>3.0.0</version>
</dependency>
```


Also see the [PDFBox 3.0 example](https://github.com/manuelbl/SwissQRBill/examples/pdfbox3).

## QR Code

For the generation of the QR code itself, [Nayuki's QR code generator](https://github.com/nayuki/QR-Code-generator) is used.
Expand Down
19 changes: 19 additions & 0 deletions build_and_run_examples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh
cd examples/gradle_example
./build_and_run.sh
rm -rf target
cd ../../examples/maven_example
./build_and_run.sh
rm -rf target
cd ../../examples/kotlin_example
./build_and_run.sh
rm -rf target
cd ../../examples/append_to_pdf
./build_and_run.sh
rm -rf target
cd ../../examples/pdfbox3
./build_and_run.sh
rm -rf target
cd ../../examples/jasper_reports_rendering
./build_and_run.sh
rm -rf target
1 change: 1 addition & 0 deletions examples/gradle_example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/qrbill.svg
3 changes: 3 additions & 0 deletions examples/jasper_reports_rendering/build_and_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
mvn package
mvn exec:java -Dexec.mainClass="net.codecrete.qrbill.examples.JasperReportsRendering"
2 changes: 1 addition & 1 deletion examples/jasper_reports_rendering/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>net.codecrete.qrbill</groupId>
<artifactId>jasper-reports-rendering</artifactId>
<version>3.1.1</version>
<version>3.2.0</version>

<name>Jasper Reports Rendering</name>
<description>Demo application using Jasper Reports to generate QR bills.</description>
Expand Down
1 change: 1 addition & 0 deletions examples/kotlin_example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/qrbill.svg
2 changes: 1 addition & 1 deletion examples/kotlin_example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group 'net.codecrete.qrbill.examples'
version '3.1.1'
version '3.2.0'

repositories {
mavenLocal()
Expand Down
204 changes: 0 additions & 204 deletions examples/kotlin_example/qrbill.svg

This file was deleted.

1 change: 1 addition & 0 deletions examples/maven_example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/qrbill.svg
2 changes: 1 addition & 1 deletion examples/maven_example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>net.codecrete.qrbill</groupId>
<artifactId>maven-example</artifactId>
<packaging>jar</packaging>
<version>3.1.1</version>
<version>3.2.0</version>
<name>QR Bill Maven Example</name>

<properties>
Expand Down
1 change: 1 addition & 0 deletions examples/pdfbox3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/qrbill.pdf
16 changes: 16 additions & 0 deletions examples/pdfbox3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Example using PDFBox 3.0

The Swiss QR Bill library is built with PDFBox version 2.0 (for PDF generation). PDFBox 3.0 is new
major version. It is not fully backward compatible. The Swiss QR Bill library will detect the
newer version and will still work.

In order to use PDFBox 3.0, you need to add an explicit dependency to PDFBox version 3.0 to your project
(`pom.xml` in case you are using Maven):

```xml
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>3.0.0</version>
</dependency>
```
3 changes: 3 additions & 0 deletions examples/pdfbox3/build_and_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
mvn package
mvn exec:java -Dexec.mainClass="net.codecrete.qrbill.examples.QRBillExample"
6 changes: 6 additions & 0 deletions examples/pdfbox3/maven-example.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="SonarLintModuleSettings">
<option name="uniqueId" value="7dddf75d-c4d3-4ac8-b2a6-068fa48fc650" />
</component>
</module>
Loading

0 comments on commit 0f221a7

Please sign in to comment.