Jspdf: Please add support for Japanese character

Created on 18 Dec 2018  ·  2Comments  ·  Source: MrRio/jsPDF

Thank you for submitting an issue to jsPDF. Please read carefully.

Are you using the latest version of jsPDF?
Yes.
"jspdf": "^1.4.1"

Have you tried using jspdf.debug.js?
No?

Steps to reproduce
Please insert:
doc.text(20, 40, 'ひらがなカタカナ漢字romaji');

What I saw
þÿ0r0‰0L0j0«0¿0«0Êo"[Wromaji

What I expected
ひらがなカタカナ漢字romaji

Most helpful comment

@arasabbasi
Can you please let me know where I need to add generated js-File into my project ?

All 2 comments

https://rawgit.com/MrRio/jsPDF/8f6cf40/

Choose Japanese as example and you can write japanese. But keep in mind:

The 14 standard fonts in PDF are limited to the ASCII-codepage. If you want to use UTF-8 you have to to integrate a custom font, which provides the needed glyphs. jsPDF supports .ttf-files. So if you want to have for example chinese text in your pdf, your font has to have the necessary chinese glyphs. So check if your font supports the wanted glyphs or else it will show a blank space instead of the text.

To add the font to jsPDF use our fontconverter in /fontconver/fontconverter.html . The fontconverter will create a js-file with the content of the provided ttf-file as base64 encoded string and additional code for jsPDF. You just have to add this generated js-File to your project. You are then ready to go to use setFont-method in your code and write your UTF-8 encoded text.

@arasabbasi
Can you please let me know where I need to add generated js-File into my project ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tarekis picture tarekis  ·  4Comments

BarathArivazhagan picture BarathArivazhagan  ·  4Comments

NoFootDancer picture NoFootDancer  ·  3Comments

sajesh1985 picture sajesh1985  ·  5Comments

MaxCodeDE picture MaxCodeDE  ·  4Comments