strzibny / invoice_printer

Super simple PDF invoicing
MIT License
876 stars 71 forks source link

a place for an "introductory sentence" and a QR code #72

Closed samozrejmost closed 1 year ago

samozrejmost commented 2 years ago

Hi,

I've checked out different command line tools to generate pdf invoices from the command line and yours looks most promising for me :) But (there's always a "but") would it be possible to add

Introductory sentence

I mean something along the lines of We invoice you for... or In accordance with the Contract No 2021/56844 we are sending you... A similar section is called "Additional information" in the example below:

Invoice sample

QR code

This would really be a great addition, it's becoming more and more popular and my clients would certainly appreciate not having to copy the data from the invoice by hand. I don't mean writing extra code to generate such an image (I use qrencode for that), just a suitable place for a QR code image.

Thanks for your great work!

strzibny commented 2 years ago

Yes, I wanted to add the QR code myself, and I was thinking about a similar textbox too (I had a promo in my mind).

So I will happily address both (with time), or accept these contributions if you feel like you might want to try to tackle them (if yes, let's talk first about the positions).

samozrejmost commented 2 years ago

I wish I could contribute! I've never done any Ruby or Prawn coding!

That said, after one week of waiting for your answer I opened the code and started to make some sense of it. Then I adjusted a variable here and there and this is what I came up with:

$ diff document.rb document.rb.backup 
51,52d50
<                 # Preface
<                 :preface,
81d78
<           preface: json['preface'],
109d105
<                    preface: nil,
133d128
<       @preface = String(preface)
163d157
<         'preface': @preface,
$ diff pdf_document.rb pdf_document.rb.backup 
41d40
<       preface: '',
175d173
<       build_preface
655,671d652
<     # Build preface
<     #
<     # ############################
<     #
<     def build_preface
<       @pdf.move_down(23 + @push_items_table + @push_down)
<       #@pdf.move_down(25)
< 
<       @pdf.text_box(
<         @document.preface,
<         size: 12,
<         at: [x(5), y(420) - @push_down],
<         width: x(540),
<         align: :left
<       )
<     end
< 
693c674
<       @pdf.move_down(50)
---
>       @pdf.move_down(23 + @push_items_table + @push_down)
866c847,848
<         @pdf.image(@logo, align: :left, fit: [128, 128])
---
>         bottom = @document.note.empty? ? 75 : (75 + note_height)
>         @pdf.image(@logo, at: [0, bottom], fit: [200, 50])

The resulting pdf file looks something like this: out

As you can see, I used the --logo option for the QR code but moved it upwards and out of the footer I guess.

Hope this is of some help.

Thanks again for your great program! Saved me from countless hours of tedious accounting work!

martin

strzibny commented 1 year ago

I just released 2.3.0 with a description field. I'll make a new issue for tracking the QR code.