hajareshyam / pdf-creator-node

This package is used to generate HTML to PDF in Nodejs
MIT License
238 stars 80 forks source link

Format numbers #91

Open jajajaniiiine opened 2 years ago

jajajaniiiine commented 2 years ago

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 commented 1 year ago

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

jajajaniiiine commented 1 year ago

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 commented 1 year ago

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.