Turns out this is a font issue:
unicode works, but you must make sure that the font you use includes the characters you want to use. Unlike your operating system, PDFKit does not automatically replace the font.
Source: Reddit / u / devongovett Comment
I tested two fonts that were included in the pdfkit file. Both Helvetica-Bold and Times-Roman did not work with unicode characters. I noticed in the documentation for fonts that you can add to your own fonts, so I gave Cardo Font (hosted on Google Fonts) as it supports a lot of Unicode characters.
Of course it worked. Here is the script I used for testing (make sure you have the Cardo font):
var PDFDocument = require('pdfkit'); var doc = new PDFDocument(); doc.registerFont('Cardo', 'Cardo/Cardo-Regular.ttf') doc.font('Cardo') .fontSize(20) .text('Testing [\u20AC]', 10, 10); doc.write('out.pdf');
If you are configured to use Helvetica-Bold, download a copy of the font elsewhere (make sure that it supports the unicode characters that you have after it) and register it as I have with the Cardo font.
source share