2

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.

SpeedOfRound
  • 1,210
  • 11
  • 26
  • [This answer](https://stackoverflow.com/a/44445460/2463368) mentions having to use the need_appearances flag with pdftk when filling a form with non-ASCII characters. – John Feb 19 '20 at 15:31
  • unfortunately does not seem to solve the issue. – SpringsTea Feb 22 '20 at 18:27

1 Answers1

0

It's a seven years old Poppler bug without a solution: https://gitlab.freedesktop.org/poppler/poppler/-/issues/362

int_ua
  • 1,646
  • 2
  • 18
  • 32