Is it possible to display the Euro symbol in pdfkit for nodejs without having to embed an external font?
I am using pdfKit to generate invoices and would like to prefix my currency amounts with the Euro Symbol (€).
I've tried a number of approaches and none worked:
doc.font('Helvetica-Bold')
.fontSize(12)
.text('€', 10, 10); // Alt+0128 on keypad
doc.font('Helvetica-Bold')
.fontSize(12)
.text('\u20AC', 10, 10);
Turns out it is a font issue:
Source: Reddit Thread comment by /u/devongovett
I tested two fonts that were included with pdfkit. Both 'Helvetica-Bold' and 'Times-Roman' didn't work with the unicode symbols. I noticed in the documentation for fonts that you can add in your own fonts, so I gave the Cardo Font (hosted on Google Fonts) a go as it supports many unicode characters.
Sure enough, it worked. Here is the script I used for testing (Make sure you have the Cardo font available):
If you're set on using Helvetica-Bold, download a copy of the font elsewhere (make sure it supports the unicode characters you're after) and register it as I have with the Cardo font.