Closed Anastasia-Gorobets closed 8 months ago
This is currently not possible as the QR-Bill would not fit in 150mm width. The only supported sizes are "A4"
and "A6/5"
.
With SwissQRBill v4, it is now possible to create the PDF document independently from the QR bill. This allows you to create pages with any size.
To conform the specifications, the page the QR bill gets attached will still use the sizes required by the specifications.
Example:
import { createWriteStream } from "node:fs";
import PDFDocument from "pdfkit";
import { SwissQRBill } from "swissqrbill/pdf";
import { mm2pt } from "swissqrbill/utils";
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-pdf-size.pdf");
const pdf = new PDFDocument({ size: [mm2pt(150), mm2pt(300)] });
const qrBill = new SwissQRBill(data);
qrBill.attachTo(pdf);
pdf.pipe(stream);
pdf.end();
Hello. Can you please help, how how I set width for pdf? I see there are only to formats 'A4' and 'A7'. But if I need have width like 150mm?
Thanks.