Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwissQRBill.PDF options Request #405

Closed
Tracked by #414
SaschaStu opened this issue Apr 13, 2023 · 2 comments
Closed
Tracked by #414

SwissQRBill.PDF options Request #405

SaschaStu opened this issue Apr 13, 2023 · 2 comments
Assignees
Labels
feature request New feature or request

Comments

@SaschaStu
Copy link

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

@schoero
Copy link
Owner

schoero commented Apr 14, 2023

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.

@schoero schoero added the feature request New feature or request label Apr 14, 2023
@schoero schoero self-assigned this Apr 14, 2023
@schoero schoero mentioned this issue Sep 10, 2023
29 tasks
@schoero
Copy link
Owner

schoero commented Nov 10, 2023

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();

@schoero schoero closed this as completed Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants