Closed HatemMahmoud closed 3 years ago
Hey @HatemMahmoud!
Probably the best way of doing that would be to create like a ThermalReceipt class or something that redefines the methods for generating the receipt. You'll basically have to tweak the bounding boxes and things to get a smaller size and then the same for fonts and stuff.
It might be a good time to refactor all the code for the receipt so that all the margin values and things could be configurable in a hash early on instead of being hardcoded.
The message on the header of the receipt can be overridden by simply including a message attribute when creating the new receipt in the Charge model:
def receipt
Receipts::Receipt.new(
id: id,
message: "My custom message text",
...
Probably the best way of doing that would be to create like a ThermalReceipt class or something that redefines the methods for generating the receipt. You'll basically have to tweak the bounding boxes and things to get a smaller size and then the same for fonts and stuff.
Does this also work when attempting to change the size of the print paper, e.g printing to A5?
Yep, changing the size of the paper larger or smaller would need the same tweaks.
If someone wants to make a PR for customizable sizes, that'd be awesome!
Hi,
Thanks for the great gem!
How can you customize the layout of the pdf to use smaller margins and smaller fonts for printing on small thermal paper? Also, how could you add a logo and update the message on the header of the receipt?
Thank you!