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

How to customize the layout for a receipt printer? #7

Closed
HatemMahmoud opened this issue Jul 14, 2017 · 4 comments
Closed

How to customize the layout for a receipt printer? #7

HatemMahmoud opened this issue Jul 14, 2017 · 4 comments
Labels

Comments

@HatemMahmoud
Copy link

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!

@excid3
Copy link
Owner

excid3 commented Jul 14, 2017

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.

@Dragonicity
Copy link

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",
...

@kudapara
Copy link

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?

@excid3
Copy link
Owner

excid3 commented Feb 18, 2021

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants