Closed samayo closed 2 years ago
You can import the library using a html script tag:
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/swissqrbill/lib/browser/bundle/index.js" defer></script>
You can then access the library using a global constant named SwissQRBill
.
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"
},
debtor: {
name: "Pia-Maria Rutschmann-Schnyder",
address: "Grosse Marktgasse 28",
zip: 9400,
city: "Rorschach",
country: "CH"
}
};
const stream = new SwissQRBill.BlobStream();
const pdf = new SwissQRBill.PDF(data, stream);
pdf.on("finish", () => {
window.location.href = stream.toBlobURL("application/pdf");
});
Thanks a lot, this was very helpful 👍
Hello, thanks for creating this app, it's a real time saver.
I am currently making a small site with PHP, so I plan to use this library entirely on browser.
import/export don't work without node, so how can we initialize the class? aside from loading the cdn file?
Is there vanilla js solution that doesn't rely on node?
thank you