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

Format numbers #91

Open
jajajaniiiine opened this issue Sep 29, 2022 · 3 comments
Open

Format numbers #91

jajajaniiiine opened this issue Sep 29, 2022 · 3 comments

Comments

@jajajaniiiine
Copy link

jajajaniiiine commented Sep 29, 2022

Hi! I am generating a pdf using this library, however, the data we are displaying here has a lot of figures/numbers to be formatted, is there any way we can format those figures? Thank you.

@XXXL3J
Copy link

XXXL3J commented Dec 12, 2022

Use canvas to pre-generate those figures and add them as images

@jajajaniiiine
Copy link
Author

Use canvas to pre-generate those figures and add them as images

Hi, what I mean by figures is the amount, the total amount.

For example:
the total amount that we got is 64342.94, and upon printing the PDF this total amount is formatted to $64,342.94.

We do have a formatting library which is the Numeral.js, however, we cannot use it on the HTML file for this is used for JS files, so, is there a way that we can do this on the HTML file itself, not from the controller or client-side? Thank you.

@XXXL3J
Copy link

XXXL3J commented Dec 14, 2022

OK, it seems that you want a specific format for financial numbers.

Suggestion:
You can convert them with Numeral.js, before passing data to pdf-creator-node.
let your_amount = 64342.94; your_amount = '$' + numeral(your_amount).format('0,0');
Only use this pdf-creator-node as a pdf render, instead of a formatting tool.

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

No branches or pull requests

2 participants