This repository is an example how you could bundle SwissQRBill > v3.0.0 by yourself using webpack for the usage inside a browser. For instructions on SwissQRBill v2.x visit this link.
import { PDF, BlobStream } from "swissqrbill/browser";
const data: SwissQRBill.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"
},
debtor: {
name: "Pia-Maria Rutschmann-Schnyder",
address: "Grosse Marktgasse 28",
zip: 9400,
city: "Rorschach",
country: "CH"
}
};
const stream = new BlobStream();
const pdf = new PDF(data, stream);
pdf.on("finish", () => {
window.location.href = stream.toBlobURL("application/pdf");
});
To test, please clone this repo and run it locally using the following commands:
git clone https://github.com/schoero/SwissQRBill-browser-example.git
cd SwissQRBill-browser-example && npm install
npm run start
Open http://localhost:8000/pdf.html or http://localhost:8000/svg.html in your browser. You should see a generated pdf/svg that looks like this: