Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PDFSharp with Chinese characters

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.

like image 375
bastek.d Avatar asked Jun 06 '26 10:06

bastek.d


1 Answers

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;
like image 187
Malhotra Avatar answered Jun 08 '26 23:06

Malhotra



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!