Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
swissqrbill
Advanced tools
With SwissQRBill you can easily generate the new QR Code payment slips as a PDF or SVG in Node.js and the browser. The new QR Code payment slips were introduced in Switzerland on June 30th, 2020 and replaces the old payment slips since October 1st, 2022. In addition to the payment section, you can generate a complete invoice with PDFKit by inserting your own content above the payment section.
Invoices are a critical part of every business. Keeping this library up-to-date with the extensive specifications takes time and effort.
If this library has been valuable to you, please consider becoming a sponsor, or make a one time donation to support its ongoing development.
npm i swissqrbill
SwissQRBill is based around PDFKit. Depending on the environment you are using, you may need to import the libraries differently. Please read the importing documentation to find out the best way to import the libraries for your environment.
Once you have imported SwissQRBill and PDFKit, it is quite easy to create a simple QR bill. All you have to do is to create a new SwissQRBill
instance with your billing data object. You can then attach the QR bill to any PDFKit document.
import { createWriteStream } from "node:fs";
import PDFDocument from "pdfkit";
import { SwissQRBill } from "swissqrbill/pdf";
const data = {
amount: 1994.75,
creditor: {
account: "CH44 3199 9123 0008 8901 2",
address: "Musterstrasse",
buildingNumber: 7,
city: "Musterstadt",
country: "CH",
name: "SwissQRBill",
zip: 1234
},
currency: "CHF",
debtor: {
address: "Musterstrasse",
buildingNumber: 1,
city: "Musterstadt",
country: "CH",
name: "Peter Muster",
zip: 1234
},
reference: "21 00000 00003 13947 14300 09017"
};
const pdf = new PDFDocument({ size: "A4" });
const qrBill = new SwissQRBill(data);
const stream = createWriteStream("qr-bill.pdf");
qrBill.attachTo(pdf);
pdf.pipe(stream);
pdf.end();
This will create the PDF file above. You can pass an optional parameter containing options to the SwissQRBill constructor
.
A complete documentation for all methods and parameters can be found in the docs/ directory of this repository.
Alternatively, you could render the QR Bill as a scalable vector graphic (SVG). But keep in mind, using SVG you can only render the QR Bill part and not an entire invoice.
import { SwissQRBill } from "swissqrbill/svg";
const svg = new SwissQRBill(data);
document.body.appendChild(svg.element);
It is possible to create a complete invoice with SwissQRBill. This means that you can add your own content above the QR Bill.
SwissQRBill is based around PDFKit to generate the PDF files. You can use all the features of PDFKit to add your own content to the PDF file.
The documentation for PDFKit can be found on pdfkit.org.
A simple guide how to generate a complete bill can be found in docs/how-to-create-a-complete-qr-bill.md. You will learn how to create a PDF that looks like this:
FAQs
Swiss QR Bill generation in Node.js and browsers
The npm package swissqrbill receives a total of 1,613 weekly downloads. As such, swissqrbill popularity was classified as popular.
We found that swissqrbill demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.