-
Notifications
You must be signed in to change notification settings - Fork 4.7k
.html method can't handle Chinese correctly, even after used the .setFont method. #2465
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
Comments
How does .html know that it should use that chinese font? So you should have to do something like |
Isn't the |
ok my last post had the html-markup parsed
|
Hi I am also facing the same issue while trying to convert my Japanese div to pdf.
It is generating garbage text. No luck. Is there any other solution for this. I have generated font js using the instructions provided in repo still no luck. |
@ShubhamOrbio |
I added the font in my project folder after including jspdf script.
|
@arasabbasi Thank you, I will learn more about PDF then have another try to fix UTF-8 and typesetting~ |
ok you use font-family, but not setting that the text should be bold by doing e.g. font-weight: bold? |
Font-weight bold is also not working out. Output is same the garbage text |
Ok so after spending few hours I can print Japanese text using .text method here. something like this:
but no luck with this code. it still prints garbage data. any help will be appreciated
|
yeah, using fromHTML should defiitly result in garbage. |
By far this is the best solution I have got.
Please let me know if you guys have any better solution |
can you help me with a better solution please so that I can convert my div to pdf which is in Japanese |
till now you did not supply me with a jsfiddle or so. So how can I help you? |
Sorry my bad. |
@arasabbasi When I generated a font js from fontconverter.html , and it's |
Yes, thats expected behaviour. |
@Uzlopak did you solve the problem that jdpdf.html() API don't support custom font?
|
if doc.setFont('fontname') works then setting font-family:'fontname' should work as well. |
hello,have you solved this problem? I also meet that " fontType:blod" doesn't work when I added Chinese characters. |
Hello you guys, I got the same issue. I can't use Japanese in PDF. I added font, setFont...But it just work when use doc.text not doc.html(''). |
@Saggv , .html is another method, so to set the font do the following
This solution has already been mentioned :) , kudos |
@kamranmuazzam Thank you for you answer...I do the same thing as you said but it does not work. I don't know why :)) Thank you |
I found a way to render custom font.
|
very useful. |
Hello, I'm using
jsPDF
1.5.3
version, but I found Chinese doesn't display correctly when I use.html
method. But it will work when I use the.text
method.This makes me confused. So, does there any solutions, for trans a Chinese HTML page to PDF
with using the awesome
jsPDF
? I will be very grateful for this 😊.Here are my scripts:( I'm using
SourceHanSansCN.ttf
for Chinese, you can find it from here: Source-Han-TrueType )Here is my javascript code:
The text was updated successfully, but these errors were encountered: