Closed skch-17 closed 8 months ago
Thank you for the contribution. I have released you changes with SwissQRBill v4.0.0.
Keep in mind, that the font has to be registered before using. You can now change the font like this:
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 stream = createWriteStream("different-font.pdf");
const pdf = new PDFDocument({ autoFirstPage: false });
// Register the font
pdf.registerFont("Liberation-Sans", "path/to/LiberationSans-Regular.ttf");
pdf.registerFont("Liberation-Sans-Bold", "path/to/LiberationSans-Bold.ttf");
const qrBill = new SwissQRBill(data, { fontName: "Liberation-Sans" });
qrBill.attachTo(pdf);
pdf.pipe(stream);
pdf.end();
@schoero Morning As we currently have the requirement to create PDF/A-2b, we need to adjust the font for the QR-Bill so that we are able to embed it into the pdf. As 'Helvetica' is a .afm font in PDFKit it is not embeddable. That's why we use now Liberation-Sans as it is compatible with the Swiss-QR-Standards and free of charge.
I opened a pull request so that you see the changes I made. As my fork is in quite strange state, so that we can work you probably must decline the pull or remove the change to the addPath.