-
-
Notifications
You must be signed in to change notification settings - Fork 844
Description
What were you trying to do?
I'm trying to generate a PDF with user-generated text in a lot of different languages / scripts. I'm using a font that includes a large portion of Japanese, Traditional Chinese, Simplified Chinese, and Korean. It is a huge font, so I'd like to use {subset: true} so that the entire font isn't embedded into the PDF.
How did you attempt to do it?
- Embed the font that contains the CJK scripts. Use {subset: true}
- Render the text using drawText
What actually happened?
Many character don't show up in the final PDF.
However! If I take out {subset: true} then the character show up, but the PDF is huge because it contains a huge font.
Here is the PDF. It should show these characters:
私は日本語を書かないので機械翻訳を使ってバグ
再現用のこのテキストを作成しました
As you'll see, most are missing. ScribbleTogether (34).pdf
What did you expect to happen?
The character should show up even when {subset: true} is enabled, which results in a PDF with the right characters that is also a manageable size.
How can we reproduce the issue?
I'm really having trouble with this JS Fiddle! It should show the bug but is stuck on a different unrelated error. https://jsfiddle.net/bridger/ehdajb6c/21/
It produces an error when encoding the string, which doesn't happen in my webpack builds. This unrelated error showing up in JSFiddle is "Error: Not a fixed size". It seems to come from https://github.com/foliojs/restructure/blob/7b2f4b07d8ca154827afc9fd2b6aa8e20812a421/src/utils.js#L19 according to foliojs/pdfkit#1359
Version
1.17.1
What environment are you running pdf-lib in?
Browser
Checklist
- My report includes a Short, Self Contained, Correct (Compilable) Example.
- I have attached all PDFs, images, and other files needed to run my SSCCE.
Additional Notes
No response