I am filling pdf forms and serving them to users on my express web server:
const pdfFillForm = require('pdf-fill-form');
let FillData = {
text: 'Title'
}
const pdf = pdfFillForm.writeSync(Form.path,
FillData, { "save": "pdf" } );
res.setHeader('Content-Disposition', 'attachment; filename=' + `filename.pdf`);
res.type("application/pdf");
res.send(pdf);
The above code works fine, until the contents of FillData
contains Asian characters.
Any non-English character renders blank. I have also tried a very similar setup using another similar library fill-pdf
, which uses a different library under the hood. But this lib has a similar problem, characters are encoded incorrectly, something like:
ã…Žã…«ã‡¼ã…«ã‡°ç”‰åł½ç¬¬ä¸•ç”‰å¥³ ㇢㇤ㅪㇹ
How can I correctly encode my pdfs to display both languages? Any alternatives? I understand this issue likely stems from pdftk
and Poppler
. Both of these node libs allow you to pass configuration args, but I have been unable to find any documentation regarding encoding in these libs.