PDFsharp & MigraDoc Foundation

Chinese characters
Page 1 of 1

Author:  BrianTheK [ Thu Nov 29, 2018 4:56 pm ]
Post subject:  Chinese characters

Hi. I am attempting to get unicode characters to display. For example Chinese and Korean. I only get squares. I am trying to use the font "arialuni.ttf" and get it embedded it in the pdf. Its in my fonts folder. I've read the posts about unicode characters and it seems like it should work if I can get the font embedded. Right now, its not shown in the pdf properties. I don't think its finding arialuni.ttf in my fonts folder.

Document document = new Document();
document.Info.Title = "Created with MigraDoc";
Section section = document.AddSection();
section.PageSetup.PageFormat = PageFormat.Letter;   //A4;

// unicode text
// must use a unicode font like arialuni.ttf
Paragraph paragraph = section.AddParagraph();
paragraph.Format.Font = new MigraDoc.DocumentObjectModel.Font("Arial Unicode MS Regular", Unit.FromPoint(12));

paragraph.AddText("This is Chinese: " + "来自美国的你好");
paragraph.AddText("This is Korean: " + "미국에서 온 안녕하세요");

// render to a pdf
PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);

// pass the document to the renderer:
 pdfRenderer.Document = document;

 string filename = BASE_PATH + "HelloWord.pdf";

Author:  TH-Soft [ Thu Nov 29, 2018 7:51 pm ]
Post subject:  Re: Chinese characters

BrianTheK wrote:
I don't think its finding arialuni.ttf in my fonts folder.
Are you sure "Arial Unicode MS Regular" is the correct name for arialuni.ttf and that there are Chinese characters in that file?
I don't have that file on my computer.

Author:  TH-Soft [ Fri Nov 30, 2018 7:49 am ]
Post subject:  Re: Chinese characters

Problem was solved:

Font name should be ""Arial Unicode MS" here.
In most cases "Regular" or "Bold" are not part of the font name used in MigraDoc/PDFsharp - but it depends on how the font was designed. Font designers can do it either way.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group