PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Dec 12, 2018 3:25 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Chinese characters
PostPosted: Thu Nov 29, 2018 4:56 pm 
Offline

Joined: Wed Nov 21, 2018 5:48 pm
Posts: 13
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.

Code:
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;

 pdfRenderer.RenderDocument();
 string filename = BASE_PATH + "HelloWord.pdf";
pdfRenderer.PdfDocument.Save(filename);


Top
 Profile  
Reply with quote  
 Post subject: Re: Chinese characters
PostPosted: Thu Nov 29, 2018 7:51 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 429
Location: CCAA
Hi!
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.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
 Post subject: Re: Chinese characters
PostPosted: Fri Nov 30, 2018 7:49 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 429
Location: CCAA
Problem was solved:
https://stackoverflow.com/q/53545002/1015447

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.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group