Closed SaschaStu closed 8 months ago
SwissQRBill requires a fixed page margin to be conformant with the specifications. But I agree that it should be more flexible and this should only apply to the page on which the payment part is rendered.
This requires some internal refactorings, but I will look into it.
With SwissQRBill v4, it is now possible to create the PDF document independently from the QR bill. This allows you to change the margin and use any other PDFKit features.
To conform the specifications, the page the QR bill gets attached will still use the margin required by the specifications.
Example:
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 stream = createWriteStream("zero-margin.pdf");
const pdf = new PDFDocument({ margin: 0 });
const qrBill = new SwissQRBill(data);
pdf.text("This page has zero margin!");
pdf.pipe(stream);
qrBill.attachTo(pdf);
pdf.end();
Hi, with PDFKit you can set a option called autoFirstPage to false. Would be wonderful, if you could add this option, because i'm not able to change the page margin on the first page
Best, Sascha