damoiser / qr-bills

Ruby Gem to generate QR-Bills for Swiss payments
BSD 3-Clause "New" or "Revised" License
21 stars 15 forks source link

Support native Prawn template #27

Open 800a7b32 opened 2 years ago

800a7b32 commented 2 years ago

This PR provides native prawn templates for the QR-Bills gem. The prawn block is wrapped in #canvas as per prawn specs

damoiser commented 2 years ago

Hello @800a7b32, thanks for the PR! Seen that this is a bit important changes, I would require to check deeper your code changes, will do that as soon I will have some spare time and provide feedback on the code.

Thanks again!

danielpuglisi commented 1 year ago

If I may add some input: I would recommend replacing QRPRAWNLayout with a prawn extension module like so https://prawnpdf.org/docs/0.11.1/Prawn/Document.html#method-c-extensions (e.g. call it QRBills::PrawnExtension).

With this there is no need for additional params and layout logic and one can just simply add the extension and use it within their pdf workflow.

An example:

  Prawn::Document.extensions << QRBills::PrawnExtension

  Prawn::Document.generate("foo.pdf") do
    qr_bills_payslip(qr_bills_params)
  end