Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsPDF does not support utf8 out of the box #354

Closed
michael-markl opened this issue Apr 28, 2021 · 8 comments · Fixed by #474
Closed

jsPDF does not support utf8 out of the box #354

michael-markl opened this issue Apr 28, 2021 · 8 comments · Fixed by #474
Labels
Bug Something isn't working prio: high Issue must be solved within the next weeks.

Comments

@michael-markl
Copy link
Member

Describe the bug
jsPDF does not support utf8 out of the box.
Nevertheless, we should be able to render names from different countries from all over the world.
Also we'd like to have the German quotation marks for the sentence in the manual

1. Laden Sie sich die App "Ehrenamtskarte" herunter.

To Reproduce
Steps to reproduce the behavior:

  1. Go to Administration, Karten drucken, Name etwa عائشة
  2. Click on 'Karten drucken'
  3. See errorneous PDF:

Expected behavior
The PDF should render the arabic name fine.

Screenshots
image

@michael-markl michael-markl added the Bug Something isn't working label Apr 28, 2021
@maxammann maxammann added the prio: high Issue must be solved within the next weeks. label Jan 19, 2022
@maxammann maxammann added this to the Issuing of "Anmeldecodes" milestone Jan 19, 2022
@maxammann
Copy link
Member

Solution is to add a TTF font to the PDF: https://github.com/parallax/jsPDF#use-of-unicode-characters--utf-8

This is quite a whacky solution as we never know which glyphs we will need. Sending a 200Mb TTF file to the client is not a solution..

@maxammann
Copy link
Member

I see a few options:

  • Just use the most wildly used Glyphs: Noto Sans
    • People with Japanese/Chinese names properly have some latin translations for their names. Are there internaptional passports with for example chinese characters?
  • Create PDF on Server - no option because of privacy?
  • Fetch needed TTFs dynamically based on the used glyphs
    • very complicated
    • leaks information about glyphs in the names of people

@michael-markl
Copy link
Member Author

michael-markl commented Jan 25, 2022

Lets do TeX :D
https://github.com/manuels/texlive.js

@maxammann
Copy link
Member

Haha lets download the 2GB texlive distro into cookies :D

@michael-markl
Copy link
Member Author

haha it's actually not that much:
The live demo only uses up to 10MB to produce this PDF.
If you remove the usages of the packages (amsmath and graphicx) it is actually quite light weight and also fast enough for production^^

http://manuels.github.io/texlive.js/#open_pdf

@maxammann
Copy link
Member

Latex also needs to get the fonts somewhere :D So the issue is not any different with latex vs. pdfjs.

@michael-markl
Copy link
Member Author

Huh, good question how that would work then... But if it works well enough, it would be worth a try 😅 this would also improve the layout a lot (and make it easier) I guess.

@maxammann
Copy link
Member

Download 1GB of font files :D There is no other way actually. In order to generate arbitrary PDFs with arbitrary glphys, you need to have all the glyphs available in the environment from which the PDF is generated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working prio: high Issue must be solved within the next weeks.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants