strzibny / invoice_printer

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

US letter version for envelopes #12

Closed otrosien closed 3 years ago

otrosien commented 8 years ago

I have a question that I haven't found answered in the readme. How can I handle the following localization issues with invoice_printer:

Thanks, Oliver

strzibny commented 7 years ago

Hi,

A4 vs. US letter placement of recipient and seller address (i.e. for envelopes with window)

There is no US letter version. It did not even cross my mind, but could be a nice feature.

formatting of date value formatting of money values - if there is any...? (the example code is a bit inconsistent, sometimes it includes $ sign, sometimes not)

The README mentions this. It's left to you to do it. This is the most flexible options as supporting any use-case people might have could be problematic. For money outputs I wrote https://github.com/strzibny/formatted-money since in Czech rep. we format money differently than in US.

janxious commented 6 years ago

@strzibny I saw your post about 1.0 on reddit and went poking about. I thought a little about the problem and started playing with a ratio-based system in this commit. Have any thoughts about that vs. something you might have in mind that is different?

For example, I can imagine a different approach wherein a particular document size has a set of methods that conform to the various build_* methods and one just slots in the correct page size generator when making an invoice.

rathboma commented 6 years ago

+1 for a US letter version. This looks great, but almost all US businesses use this paper size.

janxious commented 6 years ago

I guess the important thing to note is that Prawn, and thus invoice_printer, produces U.S. letter size PDFs by default, so this is more about adding A4 than adding letter. :)

strzibny commented 6 years ago

@janxious Yep, you are right. I honestly used this for electronic invoices only so far, but definitely want it to work ias expected in print both for A4 and letter version. So since this is a letter version actually what does it need to change to make it usable for everyone in the US?

Otherwise yes I think you could try to work on the ratio system a bit more and report back. It's a sensible start.

janxious commented 6 years ago

I think the thing that would need to change to support see-through US envelopes is adding the ability to change where the To: address is located on the document, which I think would probably work better with a system wherein each kind of document/size has its own printer. Given it's just one feature, that might be overkill and some very particular conditional logic might be simpler short-term.

strzibny commented 6 years ago

@janxious Before we deal with the proper solution for the US envelope can finish the work you started on the ratio system? I think it will work nicely.

I would create private methods width and height that would take an argument in size for the default us letter and return correct value based on the ration calculation:

@pdf.text_box(
  @labels[:sublabels][:name],
  size: 12,
  at: [0, top_offset - @push_down - 22],
  width: width(320),
  align: :left
)
end

This way we can support A4 size for the upcoming point release.

janxious commented 6 years ago

Sure. I haven't had much time to work on OSS stuff the last couple weeks. :|

strzibny commented 6 years ago

Since you did not start until now, I am taking over to implement this. I might have something within a week.

strzibny commented 6 years ago

This is the PR if anyone is interested: https://github.com/strzibny/invoice_printer/compare/a4-format?expand=1

I am keeping this tracking issue for letter version for envelopes.

strzibny commented 3 years ago

I am closing it as stale for now, since nobody tried to tackle it. Maybe it's not as important at this time and age.

Willing to reopen if someone would pick it up.