PDFSharp with Chinese characters

ε祈祈猫儿з 提交于 2019-12-11 03:07:59

问题


I have problem with displaying Chinese characters in PDFSharp in C#. During process of creating the PDF string it's ok, but after creating pdf file it doesn't display it. I found one solution which is

XFont font_small2 = new XFont("微软雅黑", 9, XFontStyle.Regular, options)

This solutions works on my localhost but when I release this on beta server it doesn't display Chinese characters.


回答1:


You can embed original Chinese font into your pdf file and use correct CMAP.

var options = new XPdfFontOptions(PdfFontEmbedding.Always);
var font = new XFont("微软雅黑", 9, XFontStyle.Regular, options);

OR

var page = new PdfPage();
var gfx = XGraphics.FromPdfPage(page);
gfx.MFEH = PdfFontEmbedding.Automatic;



回答2:


Make sure the font is installed correctly on the beta server and make sure application has sufficient rights. Make sure the font is embedded in the PDF file.

According to the PDFsharp FAQ, CJK fonts are not supported. But still you should get the same results on server and local computer if the environments are set up correctly.



来源:https://stackoverflow.com/questions/14746920/pdfsharp-with-chinese-characters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!