Socket
Socket
Sign inDemoInstall

swissqrbill

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swissqrbill

Swiss QR Bill generation in Node.js and browsers


Version published
Weekly downloads
2.7K
decreased by-7.93%
Maintainers
1
Weekly downloads
 
Created
Source
SwissQRBill

GitHub license npm version GitHub issues npm weekly downloads GitHub repo stars GitHub workflow status




With SwissQRBill you can easily generate the new QR Code payment slips 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 SwissQRBill by inserting your own content above the payment section.



QR bill




Migration from v3 to v4

In SwissQRBill v4, large parts of the application have been rewritten to make the API more flexible. This means that you have to make some changes to your code when upgrading from v3 to v4.

Please read the migration guide to learn more about the changes and how to migrate your code.


Features

  • Generate complete invoices, or only the QR Bill, as a PDF file.
  • Generate the QR Bill as a scalable vector graphic (SVG).
  • Works in browsers and Node.js.
  • Supports german, english, italian and french invoices.
  • Allows you to add other content above the invoice using PDFKit.
  • Easy to use.
  • Free and open source.

Installation

npm i swissqrbill

Importing the library

Depending on the environment you are using, you may need to import the library differently. Please read the importing documentation to find out the best way to import the library for your environment.


Quick start

Once you have imported SwissQRBill, it is quite easy to create a simple QR bill. All you have to do is to create a new SwissQRBill instance and pass your billing data object as the first parameter and your output path as the second parameter.

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");
pdf.pipe(stream);
qrBill.attachTo(pdf);
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);


Further information

SwissQRBill uses PDFKit to generate the PDF files. The documentation for PDFKit can be found here.

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:

Complete QR bill

Keywords

FAQs

Package last updated on 10 Nov 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc