Skip to content

Commit

Permalink
Extended character set and PDF font embedding
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelbl committed May 27, 2024
1 parent 7c1545c commit 8a81019
Show file tree
Hide file tree
Showing 63 changed files with 2,448 additions and 700 deletions.
32 changes: 12 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@

Open-source Java library to generate and decode Swiss QR bills (jointly developed with the [.NET version](https://github.com/manuelbl/SwissQRBill.NET)).

Try it yourself and [create a QR bill](https://www.codecrete.net/qrbill). The code for this demonstration (Angular UI and RESTful service) can be found on [GitHub](https://github.com/manuelbl/SwissQRBillDemo) as well.
Try it yourself and [create a QR bill](https://www.codecrete.net/qrbill). The code for this demonstration (Rect UI and RESTful service) can be found on [GitHub](https://github.com/manuelbl/SwissQRBillDemo) as well.

This library implements version 2.1 of the *Swiss Implementation Guidelines QR-bill* valid since September 30, 2019, the *Style guide* released in January 2019 and *Swico Syntax Definition (S1)* from November 11, 2018.
This library implements version 2.2 and 2.3 of the *Swiss Implementation Guidelines QR-bill* from November 20, 2023, and *Swico Syntax Definition (S1)* from November 23, 2018.

## Introduction

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.
The Swiss QR bill is the QR code based payment format that started on 30 June, 2020. The payment slip is 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.

If the invoicing party adds structured bill information (VAT rates, payment conditions etc.) to the QR bill, the payer can automate booking in accounts payable. The invoicing party can also automate the accounts receivable processing as the payment includes all relevant data including a reference number. The Swiss QR bill is convenient for the payer and payee.

Expand Down Expand Up @@ -46,12 +44,12 @@ If you are using *Maven*, add the below dependency to your `pom.xml`:
<dependency>
<groupId>net.codecrete.qrbill</groupId>
<artifactId>qrbill-generator</artifactId>
<version>[3.0.0,3.999999]</version>
<version>[3.3.0,3.999999]</version>
</dependency>

If you are using *Gradle*, add the below dependency to your *build.gradle* file:

compile group: 'net.codecrete.qrbill', name: 'qrbill-generator', version: '3.0.0+'
compile group: 'net.codecrete.qrbill', name: 'qrbill-generator', version: '3.3.0+'

To generate a QR bill, you first fill in the `Bill` data structure and then call `QRBill.generate`:

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

More code examples can be found in the [examples](examples) directory.


## API Documention

[Javadoc API documentation](https://javadoc.io/doc/net.codecrete.qrbill/qrbill-generator):
Expand All @@ -132,24 +133,15 @@ 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.
## Font license

This library is compatible with both versions. It uses reflection to deal with incompatible differences.
Starting on November 21, 2025, QR bills may use an extended character set (*Extended Latin* instead of a subset of Latin-1). This library is ready for it. The extended character set can be enabled by setting the `characterSet` property of `BillFormat` to `EXTENDED_LATIN`. The current default is `LATIN_1_SUBSET`.

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):
If the extended character set is used, it is no longer possible to use the PDF standard font *Helvectica* for the text as it is restricted to the smaller *WinANSI* character set. This library will automatically switch to the *Liberation Sans* font and embed the font subset actually used. SVG and PNG ouput can continue to use other fonts.

```xml
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>3.0.0</version>
</dependency>
```
The [*Liberation Sans*](https://github.com/liberationfonts/liberation-fonts) font is included in the library. It is made available free of charge by Goolge and Red Hat under the [SIL Open Font License, Version 1.1](https://github.com/liberationfonts/liberation-fonts/blob/main/LICENSE). You will likely need to add their copyright and license information to your product. See the [license](https://github.com/liberationfonts/liberation-fonts/blob/main/LICENSE) for details.


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

## QR Code

Expand Down
3 changes: 0 additions & 3 deletions examples/pdfbox3/.gitignore

This file was deleted.

16 changes: 0 additions & 16 deletions examples/pdfbox3/README.md

This file was deleted.

3 changes: 0 additions & 3 deletions examples/pdfbox3/build_and_run.sh

This file was deleted.

6 changes: 0 additions & 6 deletions examples/pdfbox3/maven-example.iml

This file was deleted.

43 changes: 0 additions & 43 deletions examples/pdfbox3/pom.xml

This file was deleted.

This file was deleted.

Binary file removed examples/pdfbox3/src/main/resources/invoice.pdf
Binary file not shown.
41 changes: 15 additions & 26 deletions generator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@ buildscript {
}

plugins {
id 'org.sonarqube' version '4.4.1.3373'
id 'jacoco'
id 'org.sonarqube' version '5.0.0.4638'
id 'java-library'
id 'maven-publish'
id 'signing'
id 'jacoco'
}

repositories {
mavenCentral()
}

group = 'net.codecrete.qrbill'
version = '3.2.0-SNAPSHOT'
version = '3.3.0-SNAPSHOT'
archivesBaseName = 'qrbill-generator'

sourceCompatibility = 1.8

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

withJavadocJar()
withSourcesJar()
}
Expand All @@ -38,13 +39,6 @@ jar {
}
}

test {
useJUnitPlatform()
finalizedBy jacocoTestReport
reports.junitXml.required = false
reports.html.required = true
}

javadoc {
include 'net/codecrete/qrbill/canvas/*'
include 'net/codecrete/qrbill/generator/*'
Expand Down Expand Up @@ -112,26 +106,21 @@ signing {
sonar {
properties {
property 'sonar.projectName', 'Swiss QR Bill Generator (Java)'
property 'sonar.organization', 'manuelbl-github'
property 'sonar.host', 'https://sonarcloud.io'
}
}

jacocoTestReport {
dependsOn test
reports.xml.required = true
reports.csv.required = false
reports.html.required = false
}

project.tasks["sonarqube"].dependsOn "jacocoTestReport"

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
reports {
xml.required = true
}
}

dependencies {
api 'org.apache.pdfbox:pdfbox:2.0.29'
api 'org.apache.pdfbox:pdfbox:3.0.2'
implementation 'io.nayuki:qrcodegen:1.8.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.3'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.9.3'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.3'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2'
}
2 changes: 1 addition & 1 deletion generator/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
systemProp.sonar.host.url=https://sonarcloud.io
systemProp.sonar.organization=manuelbl-github
org.gradle.jvmargs='-Dfile.encoding=UTF-8'
Binary file modified generator/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion generator/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 8a81019

Please sign in to comment.