Skip to content

Commit

Permalink
docs: use sample addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
schoero committed Oct 29, 2023
1 parent bb92b6a commit 1a3e3cd
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 58 deletions.
3 changes: 1 addition & 2 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"Frutiger",
"Grosse",
"iban",
"italian",
"linebreak",
"linebreaker",
"pdfdocument",
Expand All @@ -28,8 +29,6 @@
"QRIBAN",
"QRIID",
"QRR",
"Rutschmann",
"Schnyder",
"SCOR",
"swiss",
"swissqrbill",
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ node_modules
tests/output
examples/output
lib
local
.DS_Store
.env
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,26 +87,26 @@ import PDFDocument from "pdfkit";
import { SwissQRBill } from "swissqrbill/pdf";

const data = {
amount: 1199.95,
amount: 1994.75,
creditor: {
account: "CH4431999123000889012",
address: "Rue du Lac",
buildingNumber: "1268",
city: "Biel",
account: "CH44 3199 9123 0008 8901 2",
address: "Musterstrasse",
buildingNumber: 7,
city: "Musterstadt",
country: "CH",
name: "Robert Schneider AG",
zip: 2501
name: "SwissQRBill",
zip: 1234
},
currency: "CHF",
debtor: {
address: "Grosse Marktgasse",
buildingNumber: "28",
city: "Rorschach",
address: "Musterstrasse",
buildingNumber: 1,
city: "Musterstadt",
country: "CH",
name: "Pia-Maria Rutschmann-Schnyder",
zip: 9400
name: "Peter Muster",
zip: 1234
},
reference: "210000000003139471430009017"
reference: "21 00000 00003 13947 14300 09017"
};

const pdf = new PDFDocument({ size: "A4" });
Expand Down
Binary file modified assets/complete-qr-bill.pdf
Binary file not shown.
Binary file modified assets/complete-qr-bill.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/qr-bill.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions assets/qr-bill.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/qrbill.pdf
Binary file not shown.
Binary file removed assets/qrbill.png
Binary file not shown.
1 change: 0 additions & 1 deletion assets/qrbill.svg

This file was deleted.

2 changes: 1 addition & 1 deletion assets/swissqrbill-logo-pdf.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 28 additions & 16 deletions docs/how-to-create-a-complete-bill.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,26 @@ First we create a variable containing all information we need for the QR bill. W

```ts
const data = {
amount: 2606.35,
amount: 1994.75,
creditor: {
account: "CH4431999123000889012",
address: "Bahnhofstrasse 7",
account: "CH44 3199 9123 0008 8901 2",
address: "Musterstrasse",
buildingNumber: 7,
city: "Musterstadt",
country: "CH",
name: "SwissQRBill",
zip: 1234
},
currency: "CHF",
debtor: {
address: "Grosse Marktgasse 28",
city: "Rorschach",
address: "Musterstrasse",
buildingNumber: 1,
city: "Musterstadt",
country: "CH",
name: "Pia-Maria Rutschmann-Schnyder",
zip: 9400
name: "Peter Muster",
zip: 1234
},
reference: "210000000003139471430009017"
reference: "21 00000 00003 13947 14300 09017"
};
```

Expand Down Expand Up @@ -197,6 +199,7 @@ The [`Table`][table] class takes an object as a parameter containing the rows an
const table = new Table({
rows: [
{
backgroundColor: "#4A4D51",
columns: [
{
text: "Position",
Expand All @@ -211,8 +214,11 @@ const table = new Table({
width: mm2pt(30)
}
],
fillColor: "#ECF0F1",
height: 30
font: "Helvetica-Bold",
height: 20,
padding: 5,
textColor: "#fff",
verticalAlign: "center"
}, {
columns: [
{
Expand All @@ -227,7 +233,8 @@ const table = new Table({
text: "CHF 1'540.00",
width: mm2pt(30)
}
]
],
padding: 5
}, {
columns: [
{
Expand All @@ -242,7 +249,8 @@ const table = new Table({
text: "CHF 880.00",
width: mm2pt(30)
}
]
],
padding: 5
}, {
columns: [
{
Expand All @@ -260,7 +268,8 @@ const table = new Table({
width: mm2pt(30)
}
],
height: 40
height: 40,
padding: 5
}, {
columns: [
{
Expand All @@ -275,7 +284,8 @@ const table = new Table({
text: "7.7%",
width: mm2pt(30)
}
]
],
padding: 5
}, {
columns: [
{
Expand All @@ -290,7 +300,8 @@ const table = new Table({
text: "CHF 186.35",
width: mm2pt(30)
}
]
],
padding: 5
}, {
columns: [
{
Expand All @@ -308,7 +319,8 @@ const table = new Table({
width: mm2pt(30)
}
],
height: 40
height: 40,
padding: 5
}
],
width: mm2pt(170)
Expand Down
62 changes: 38 additions & 24 deletions examples/how-to-create-a-complete-bill/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,26 @@ pdf.pipe(stream);

// QR bill data object
const data = {
amount: 2606.35,
amount: 1994.75,
creditor: {
account: "CH4431999123000889012",
address: "Bahnhofstrasse 7",
account: "CH44 3199 9123 0008 8901 2",
address: "Musterstrasse",
buildingNumber: 7,
city: "Musterstadt",
country: "CH",
name: "SwissQRBill",
zip: 1234
},
currency: "CHF",
debtor: {
address: "Grosse Marktgasse 28",
city: "Rorschach",
address: "Musterstrasse",
buildingNumber: 1,
city: "Musterstadt",
country: "CH",
name: "Pia-Maria Rutschmann-Schnyder",
zip: 9400
name: "Peter Muster",
zip: 1234
},
reference: "210000000003139471430009017"
reference: "21 00000 00003 13947 14300 09017"
};

// Add logo
Expand Down Expand Up @@ -92,6 +94,7 @@ pdf.text(`Musterstadt ${date.getDate()}.${date.getMonth() + 1}.${date.getFullYea
const table = new Table({
rows: [
{
backgroundColor: "#4A4D51",
columns: [
{
text: "Position",
Expand All @@ -106,8 +109,11 @@ const table = new Table({
width: mm2pt(30)
}
],
fillColor: "#ECF0F1",
height: 30
font: "Helvetica-Bold",
height: 20,
padding: 5,
textColor: "#fff",
verticalAlign: "center"
}, {
columns: [
{
Expand All @@ -122,7 +128,8 @@ const table = new Table({
text: "CHF 1'540.00",
width: mm2pt(30)
}
]
],
padding: 5
}, {
columns: [
{
Expand All @@ -137,7 +144,8 @@ const table = new Table({
text: "CHF 880.00",
width: mm2pt(30)
}
]
],
padding: 5
}, {
columns: [
{
Expand All @@ -155,7 +163,8 @@ const table = new Table({
width: mm2pt(30)
}
],
height: 40
height: 40,
padding: 5
}, {
columns: [
{
Expand All @@ -170,7 +179,8 @@ const table = new Table({
text: "7.7%",
width: mm2pt(30)
}
]
],
padding: 5
}, {
columns: [
{
Expand All @@ -185,7 +195,8 @@ const table = new Table({
text: "CHF 186.35",
width: mm2pt(30)
}
]
],
padding: 5
}, {
columns: [
{
Expand All @@ -203,7 +214,8 @@ const table = new Table({
width: mm2pt(30)
}
],
height: 40
height: 40,
padding: 5
}
],
width: mm2pt(170)
Expand All @@ -212,24 +224,26 @@ const table = new Table({

// QR bill data object
const qrBill = new SwissQRBill({
amount: 2606.35,
amount: 1994.75,
creditor: {
account: "CH4431999123000889012",
address: "Bahnhofstrasse 7",
account: "CH44 3199 9123 0008 8901 2",
address: "Musterstrasse",
buildingNumber: 7,
city: "Musterstadt",
country: "CH",
name: "SwissQRBill",
zip: 1234
},
currency: "CHF",
debtor: {
address: "Grosse Marktgasse 28",
city: "Rorschach",
address: "Musterstrasse",
buildingNumber: 1,
city: "Musterstadt",
country: "CH",
name: "Pia-Maria Rutschmann-Schnyder",
zip: 9400
name: "Peter Muster",
zip: 1234
},
reference: "210000000003139471430009017"
reference: "21 00000 00003 13947 14300 09017"
});

// Combine all elements
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "4.0.0-alpha.14",
"version": "4.0.0-alpha.15",
"type": "module",
"name": "swissqrbill",
"description": "Swiss QR Bill generation in Node.js and browsers",
Expand Down

0 comments on commit 1a3e3cd

Please sign in to comment.