Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

adhik13th's avatar

How to add currency at jspdf

i have a function currency money and i always use in vue blade like this

 <td>{{ price | currency}}</td>

and will showing like that :

Rp. 5.000.000 

now i using jspdf to export my price but i didnt know how to use this currency

 let totals = this.datatotal 
  ......
    doc.text(String(totals), 102, finalY + 75) // it will be showing 5000000 but i need 5.000.000

i try to

  doc.text(String(totals | currency), 102, finalY + 75) // 

but having error ReferenceError: currency is not defined"

someone can help for this ??

0 likes
1 reply
REHANalt's avatar

in JSPDF u can convert int and decimal value like this : let total =25334; total = total.toFixed(2).replace(/\d(?=(\d{3})+.)/g, '$&,');

Please or to participate in this conversation.