-
Notifications
You must be signed in to change notification settings - Fork 125
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
Document does not have any linebreak for Chinese language #16
Comments
The authors know very little about CJK and RTL, so they are not surprised about issues with non-Latin non-LTR languages. They even wrote that in the FAQ. |
Thank you for your reminding , I hope the issues showed above will be helpful for authors , and resovle it further . |
# This is the 1st commit message: Introduce xml format for serialization and deserialzion # This is the commit message empira#2: Update README.md # This is the commit message empira#3: Comment fix for release build # This is the commit message empira#4: xml parser fix # This is the commit message empira#5: last page header and footer # This is the commit message empira#6: footer fix # This is the commit message empira#7: upgrade README.md # This is the commit message empira#8: Update README.md # This is the commit message empira#9: last page header footer rendering fix # This is the commit message empira#10: ListInfo fix serialization # This is the commit message empira#11: paragraph parsing fix # This is the commit message empira#12: text parser fix # This is the commit message empira#13: support para break # This is the commit message empira#14: CDATA parser fix # This is the commit message empira#15: rounded corner radius for table cells # This is the commit message empira#16: makes DifferentLastPageHeaderFooter section aware # This is the commit message empira#17: fix cell serialization # This is the commit message empira#18: Avoid rendering failure images # This is the commit message empira#19: barcode rendering # This is the commit message empira#20: doc fix # This is the commit message empira#21: support barcode elements inside a paragraph # This is the commit message empira#22: barcode rendering fix # This is the commit message empira#23: amend README.md # This is the commit message empira#24: fix readme # This is the commit message empira#25: fix readme
Thanks, spend so much time to looking for the reason, you are right, finally got your answer. Then I also find a Stackoverflow answer says:
So I copy the ZeroWidth NonJoiner from here : https://unicode-explorer.com/c/200C then write these simple code : private readonly char _zeroWidthNonJoiner = ''; // ATTENSION: a Zero Width NonJoiner in this var
public string ZeroWidthNonJoinerString(string chinese)
{
if (string.IsNullOrEmpty(chinese))
return chinese;
StringBuilder @string = new StringBuilder();
foreach (char item in chinese)
{
@string.Append(item);
@string.Append(this._zeroWidthNonJoiner);
}
return @string.ToString();
} use the method return string then give it to Migradoc then line breaks works right: |
You are so Handsome~ |
why I use version 1.50.5147 and render the font to be "Arial Unicode MS" still can't print Chinese? |
@iDreamCXK Which Version of Migradoc and font etc do you use to successfully draw chinese characters? I use the font "Arial Unicode MS" on a windows 10 machine and only get squares.. :/ I use the nuget-package "PDFsharp-MigraDoc-wpf" version="1.50.5147" |
You can you Microsoft YaHei.It's support of Chinese |
@iDreamCXK When I use "Microsoft YaHei" my code throws an Exception in "RenderDocument()": |
Maybe you can get help from here |
Find a True Type Font (.ttf), not a True Type Collection (.ttc). |
@ThomasHoevel That's tricky on a windows 10 machine. I just found Microsoft Yahei as a ttf but can't use it on Windows 10 because I already have a TTC with the same name installed. I can't uninstall the preinstalled version because it's a system font.. bah. So i need to rename this font (don't know how) or find a different font with chinese characters.... |
Maybe you can use 宋体在 2023年8月23日,17:13,Thomas Kaegi ***@***.***> 写道:
@ThomasHoevel That's tricky on a windows 10 machine. I just found Microsoft Yahei as a ttf but can't use it on Windows 10 because I already have a TTC with the same name installed. I can't uninstall the preinstalled version because it's a system font.. bah.
So i need to rename this font (don't know how) or find a different font with chinese characters....
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
I used the font "Noto Sans CJK SC" and it worked... damn... thanks guys! |
MigraDoc does not add any linebreak for Chinese language,as shown in the figure.
However,the English paragraph can be dealt correctly.
After debugging,I have found something wrong with the method "internal override void VisitDocumentObjectCollection(DocumentObjectCollection elements)" in the project MigraDoc.DocumentObjectModel"
The method replaces every blank for a DocumentObject ,and then MigraDoc can deal with every English word correctly ! Howevery ,thers is no blank for Chinese paragraph , such as "圣诞节(Christmas)又称耶诞节、耶稣诞辰,译名为“基督弥撒”,是西方传统节日,起源于基督教,在每年公历12月25日。弥撒是教会的一种礼拜仪式。圣诞节是一个宗教节,因为把它当作耶稣的诞辰来庆祝,故名“耶诞节”。"
I add a patch for my source code , if the text contains a Chines word , the method will replace it with a DocumentObject ,as shown below.
And the MigraDoc performs well
However , I think the way to solve the problem is Low-Performance and not thorough. Other languages ,like Japanese,will also meet the same problem.Does the author have considered this problem ? The document do not have any way to resolve the problem.
The text was updated successfully, but these errors were encountered: