本文介绍了PDFSharp有中国特色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在C#中PDFSharp展示中国文字的问题。在创建PDF串它的确定过程,但创建PDF文件后,它不会显示出来。我找到了一个解决方案,它是
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.
推荐答案
您可以嵌入原中国字体到您的PDF文件,并使用正确的CMAP。
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);
或
var page = new PdfPage();
var gfx = XGraphics.FromPdfPage(page);
gfx.MFEH = PdfFontEmbedding.Automatic;
这篇关于PDFSharp有中国特色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!