jspdf-invoice-template icon indicating copy to clipboard operation
jspdf-invoice-template copied to clipboard

Japanese language

Open adamfakrullah opened this issue 2 years ago • 15 comments

Hi may I know this package can use Japanese language for pdf file such as for column. example quantity word to Japanese. Thank you

adamfakrullah avatar Apr 06 '22 04:04 adamfakrullah

Hi @adamfakrullah, Yes it should work. Just set the object parameters titles in your language.

edisonneza avatar Apr 06 '22 06:04 edisonneza

image Hi, i try change client name into Japanese language but it appear another word. U can refer the image

adamfakrullah avatar Apr 06 '22 17:04 adamfakrullah

Got it. Will do some tests on it.

edisonneza avatar Apr 06 '22 18:04 edisonneza

Thank you sir

adamfakrullah avatar Apr 06 '22 18:04 adamfakrullah

Hi sir, do you have any update about this bug? Thank youu

adamfakrullah avatar Apr 07 '22 16:04 adamfakrullah

I didn't have time to make some tests, but i think before this weekend

edisonneza avatar Apr 07 '22 18:04 edisonneza

Oh okay. Hope you can help me. Please update once you already solved this bug. Thanks

adamfakrullah avatar Apr 07 '22 18:04 adamfakrullah

I think I can't do anything about supporting Japanese language (or even Rusian), because in my tests with some words it does work, but with some others (as in the second image) it doesn't. Some chars are displayed, some others not.

image

image

edisonneza avatar Apr 08 '22 15:04 edisonneza

I think I can't do anything about supporting Japanese language (or even Rusian), because in my tests with some words it does work, but with some others (as in the second image) it doesn't. Some chars are displayed, some others not.

image

image

this is a JSPDF related issue, for me (on arabic language) i had to test multiple fonts till finally one of them was capable of showing characters in correct format.

my advice would be to search in jspdf issues and see if someone has found a fully working font in there, or try to find one urself.

i hope that this was helpful

Nabeeh-AlSawaf avatar Jun 14 '22 00:06 Nabeeh-AlSawaf

Can you please share the font you found that worked for you? @Nabeeh-AlSawaf

edisonneza avatar Jun 14 '22 09:06 edisonneza

Can you please share the font you found that worked for you? @Nabeeh-AlSawaf

first i tried the same amiri font that is used by jspdf team but downloaded it from google and that actually failed. later i tried the exact same file from their repository not from google and it magically worked.

you can find all the fonts they used in this link: https://github.com/parallax/jsPDF/tree/master/test/reference

direct link to amiri font : https://github.com/parallax/jsPDF/raw/master/test/reference/Amiri-Regular.ttf

Nabeeh-AlSawaf avatar Jun 14 '22 11:06 Nabeeh-AlSawaf

For the Arabic language understood. Thanks!

edisonneza avatar Jun 14 '22 12:06 edisonneza

Arabic language Didn't work ? Why when data is Arabic it transform to þòþàþË

ahmedkhederali avatar Dec 22 '22 13:12 ahmedkhederali

@adamfakrullah can u please make a test using this solution about JAPANESE language? https://stackoverflow.com/questions/62772841/jspdf-not-supporting-japanese-language if u find it easier use the jspdf library instead;

about ARABIC language please try this other example: https://codesandbox.io/s/js-playground-forked-19t4vw?file=/src/index.js

please write feedback about them if they worked for any of you. Thanks!

edisonneza avatar Jul 03 '23 08:07 edisonneza

for japanese language, this worked for me:

mapPdf.addFont("/NotoSansJP-Regular.ttf", "NotoSansJP-Regular", "regular");
mapPdf.setFont("NotoSansJP-Regular", "regular");
mapPdf.setFontSize(20);
mapPdf.text(text, textX, textY);

I was able to just put the downloaded ttf file in my public directory and access it from there. Might be better if I just add it to my s3 and fetch it when I need it, but it's all the same.

it is odd that I can't just set the font to what I want initially when I create mapPdf from new jsPDF() (unless I'm missing something?)

wjlee2020 avatar Dec 18 '23 09:12 wjlee2020