Skip to content

Commit

Permalink
Merge pull request #10 from Rogerrrrrrrs/development
Browse files Browse the repository at this point in the history
v1.0.6
  • Loading branch information
schoero authored Mar 3, 2020
2 parents 86bab30 + 1afc599 commit f34ac28
Show file tree
Hide file tree
Showing 31 changed files with 576 additions and 198 deletions.
37 changes: 28 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,34 @@

With SwissQRBill you can easily generate the new QR Code payment slips which will be introduced on 30 June 2020 in switzerland.

[<img src="https://raw.githubusercontent.com/Rogerrrrrrrs/SwissQRBill/development/assets/qrbill.png">](https://github.com/Rogerrrrrrrs/SwissQRBill/blob/master/assets/qrbill.pdf)


## Contents

* [Features](#features)
* [Installation](#installation)
* [Usage](#Usage)
* [API](#API)


## Features
- Generates PDF with scalable vector graphics
- Supports german, english, italian and french invoices
- Supports A4 invoices as well as A6/5 (QR Bill only)
- Supports empty fields as defined in the [specifications](https://www.paymentstandards.ch/dam/downloads/ig-qr-bill-de.pdf)
- Supports empty fields as defined in the [specifications](https://www.paymentstandards.ch/dam/downloads/ig-qr-bill-en.pdf)
- Allows you to add other content above the invoice using [PDFKit](https://github.com/foliojs/pdfkit)
- Easy to use
- Free and open source


## Installation

```
npm i swissqrbill --save
```


## Usage

```js
Expand All @@ -34,7 +40,7 @@ const SwissQRBill = require("swissqrbill");
const data = {
currency: "CHF",
amount: 1199.95,
reference: "21 00000 00003 13947 14300 09017",
reference: "210000000003139471430009017",
creditor: {
name: "Robert Schneider AG",
address: "Rue du Lac 1268",
Expand All @@ -55,13 +61,14 @@ const data = {
const bill = new SwissQRBill.PDF(data, "qrbill.pdf");
```

This will generate the following PDF file
This will generate the above PDF.

[<img src="https://raw.githubusercontent.com/Rogerrrrrrrs/SwissQRBill/development/assets/qrbill.png">](https://github.com/Rogerrrrrrrs/SwissQRBill/blob/master/assets/qrbill.pdf)

## API


### Methods

- Constructor
- [SwissQRBill.PDF(data, outputPath[, options])](#swissqrbillpdfdata-outputpath-options)
- Methods
Expand All @@ -70,38 +77,50 @@ This will generate the following PDF file
- [addQRBill()](#addqrbill)
- [mmToPoints(mm)](#mmtopointsmm)


#### SwissQRBill.PDF(data, outputPath[, options])

- data - object containing all relevant billing data.
- outputPath - string output path for the generated PDF file.
- options - object containing settings, optional.

Returns a new instance of SwissQRBill.PDF.


Returns a new instance of SwissQRBill.PDF

Available options:
- language - string: Either `"DE" | "EN" | "IT" | "FR"`. Default `"DE"`.
- size - string: Either `"A4" | "A6/5"`. Default `"A6/5"`.
- scissors - boolean: Whether you want to show the scissor icons or the text `Separate before paying in`. Default `true`.
- autoGenerate - boolean: Whether you want to atomatically finalize the PDF. When set to false you are able to add your own content to the PDF using PDFKit. Default `true`.
- autoGenerate - boolean: Whether you want to automatically finalize the PDF. When set to false you are able to add your own content to the PDF using PDFKit. Default `true`.


#### addPage()

Adds a new page to the PDF.


#### end()

Finalizes the PDF document, after this command you are no longer able to edit the PDF.
Note: This function is automatically called when the option autoGenerate is set to true.


#### addQRBill()

Adds the QR Bill to the bottom of the current page.
Note: This function is automatically called when the option autoGenerate is set to true.


#### mmToPoints(mm)

- mm - number containg the millimeters you want to convert to points.
Converts milimeters to points which are used in the PDF file.
Returns a number containing the converted millimeters in points.


## PDFKit
This module uses [PDFKit](https://github.com/foliojs/pdfkit) to generate PDF files. You are able to generate a comlete bill using PDFKit methods and then add the QR Bill to the bottom using `addQRBill()` when the option `autoGenerate` is set to `false`.

This module uses [PDFKit](https://github.com/foliojs/pdfkit) to generate PDF files. You are able to generate a complete bill using PDFKit methods and then add the QR Bill to the bottom using `addQRBill()` when the option `autoGenerate` is set to `false`.

The documentation for PDFKit can be found [here](http://pdfkit.org/docs/getting_started.html).

Expand All @@ -113,7 +132,7 @@ const SwissQRBill = require("swissqrbill");
const data = {
currency: "CHF",
amount: 1199.95,
reference: "21 00000 00003 13947 14300 09017",
reference: "210000000003139471430009017",
creditor: {
name: "Robert Schneider AG",
address: "Rue du Lac 1268",
Expand Down
Binary file modified assets/qrbill.pdf
Binary file not shown.
Binary file modified assets/qrbill.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions example/a4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const SwissQRBill = require("../");

const data = {
currency: "CHF",
amount: 1199.95,
reference: "210000000003139471430009017",
creditor: {
name: "Robert Schneider AG",
address: "Rue du Lac 1268",
zip: 2501,
city: "Biel",
account: "CH4431999123000889012",
country: "CH"
},
debitor: {
name: "Pia-Maria Rutschmann-Schnyder",
address: "Grosse Marktgasse 28",
zip: 9400,
city: "Rorschach",
country: "CH"
}
};

const bill = new SwissQRBill.PDF(data, "./output/a4.pdf", { size: "A4" });
2 changes: 1 addition & 1 deletion example/a6.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const SwissQRBill = require("../");
const data = {
currency: "CHF",
amount: 1199.95,
reference: "21 00000 00003 13947 14300 09017",
reference: "210000000003139471430009017",
creditor: {
name: "Robert Schneider AG",
address: "Rue du Lac 1268",
Expand Down
2 changes: 1 addition & 1 deletion example/multipage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const SwissQRBill = require("../");
const data = {
currency: "CHF",
amount: 1199.95,
reference: "21 00000 00003 13947 14300 09017",
reference: "210000000003139471430009017",
creditor: {
name: "Robert Schneider AG",
address: "Rue du Lac 1268",
Expand Down
24 changes: 24 additions & 0 deletions example/normal-iban-creditor-reference.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const SwissQRBill = require("../");

const data = {
currency: "CHF",
amount: 1199.95,
reference: "RF18539007547034",
creditor: {
name: "Robert Schneider AG",
address: "Rue du Lac 1268",
zip: 2501,
city: "Biel",
account: "CH5800791123000889012",
country: "CH"
},
debitor: {
name: "Pia-Maria Rutschmann-Schnyder",
address: "Grosse Marktgasse 28",
zip: 9400,
city: "Rorschach",
country: "CH"
}
};

const bill = new SwissQRBill.PDF(data, "./output/normal-iban-creditor-reference.pdf");
23 changes: 23 additions & 0 deletions example/normal-iban-no-reference.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const SwissQRBill = require("../");

const data = {
currency: "CHF",
amount: 1199.95,
creditor: {
name: "Robert Schneider AG",
address: "Rue du Lac 1268",
zip: 2501,
city: "Biel",
account: "CH5800791123000889012",
country: "CH"
},
debitor: {
name: "Pia-Maria Rutschmann-Schnyder",
address: "Grosse Marktgasse 28",
zip: 9400,
city: "Rorschach",
country: "CH"
}
};

const bill = new SwissQRBill.PDF(data, "./output/normal-iban-no-reference.pdf");
24 changes: 24 additions & 0 deletions example/qr-iban.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const SwissQRBill = require("../");

const data = {
currency: "CHF",
amount: 1199.95,
reference: "210000000003139471430009017",
creditor: {
name: "Robert Schneider AG",
address: "Rue du Lac 1268",
zip: 2501,
city: "Biel",
account: "CH4431999123000889012",
country: "CH"
},
debitor: {
name: "Pia-Maria Rutschmann-Schnyder",
address: "Grosse Marktgasse 28",
zip: 9400,
city: "Rorschach",
country: "CH"
}
};

const bill = new SwissQRBill.PDF(data, "./output/qr-iban.pdf");
45 changes: 1 addition & 44 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swissqrbill",
"version": "1.0.5",
"version": "1.0.6",
"description": "Swiss QR Bill generation in node.js ",
"main": "./index.js",
"types": "./lib/index.d.ts",
Expand Down
Loading

0 comments on commit f34ac28

Please sign in to comment.