We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

PDF cannot render strings in some languages (Chinese simplified, Japanese)

Thread ID:

Created:

Updated:

Platform:

Replies:

126942 Oct 17,2016 05:30 PM UTC Jun 5,2017 06:16 AM UTC Xamarin.Forms 5
loading
Tags: PDF
Jeff Lindborg
Asked On October 17, 2016 05:30 PM UTC

using the PdfGraphics "DrawSring" method, I'm passing in a unicode string that looks like this (for Chinese simplified):


过去 7 天内的血糖平均 : 111.37 mg/dL

this renders properly everywhere, including on the graph titles and axis and such, but the PDF control only allows for 5 fonts to be passed to the DrawString as the PdfFont parameter - I tried all 5 and the above string renders in the PDF output as:

7 : 111.37 mg/dL

For other languages like German, French, Spanish etc... it renders fine, of course - just graphical languages that require special fonts - Word uses "Microsoft JhengHei" for this, it can also use "MS Gothic" and the like.  

Just checking if there's something simple I'm missing or if the PDF component does not support rendering strings for all languages.

thanks


Sasi Kumar Sekar [Syncfusion]
Replied On October 18, 2016 02:20 PM UTC

Hi Jeff, 

Thank you for contacting Syncfusion support, 

We can draw the text using different font using the PdfTruetypeFont, please find the below code snippet to load the different font file to PdfTrueTypeFont to draw the string. 
 
Stream fontStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("jhenghei.ttf");  PdfTrueTypeFont font = new PdfTrueTypeFont(fontStream, 12); 
page.Graphics.DrawString("过去 7 天内的血糖平均", font, PdfBrushes.Black, new PointF(10, 10)); 
 

We have created the sample to preserve the given Chinese character by mentioned  JhengHei TrueType Font file. Please find the sample link below for your reference. 
Sample link: 

Please let us know if you have need further assistance. 
Regards, 
Sasi kumar S. 


Jeff Lindborg
Replied On October 18, 2016 04:16 PM UTC

cool - the arialuni.ttf font included in your sample project works for all languages I tried it against (Hindi, Arabic, Japanese, Chinese simplified) - so that will work out find.

thanks much.

Sasi Kumar Sekar [Syncfusion]
Replied On October 19, 2016 07:16 AM UTC

Hi Jeff, 
Thank you for your update, 
Please let us know if you need further assistance. 
Regards, 
Sasi kumar S. 


Slobodan Babic
Replied On June 2, 2017 11:24 AM UTC

Hello.
I am having a similar issue while working with PDF files, only difference is that contain text form fields - some specific Unicode characters are not rendering properly when using PdfStandardFont.
Can I somehow set the font property for textual form field, and then use PdfTrueTypeFont that I obtained from resources for fields?

Sasi Kumar Sekar [Syncfusion]
Replied On June 5, 2017 06:16 AM UTC

Hi Jeff, 
 
Thank you for your update, 
 
In default the PDF Standard fonts is not supported for all Unicode characters, we have preferred the Truetype fonts to preserve the Unicode characters. Please find the UG documentation link for embedding and working with the Unicode character. 
 
UG documentation link: 
 
We can set the font for the specific form field by using the Font property. Please find the code snippet to set font to the form field. 
Code snippet: 
//Create a new PDF document. 
PdfDocument document = new PdfDocument(); 
 
//Add a new page to the PDF document. 
PdfPage page = document.Pages.Add(); 
 
//Create a textbox field and add the properties. 
PdfTextBoxField textBoxField = new PdfTextBoxField(page, "CompanyName"); 
  
Stream fontStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("jhenghei.ttf"); 
 
PdfTrueTypeFont font = new PdfTrueTypeFont(fontStream, 12);  
 
//Set the font to the form field. 
textBoxField.Font = font; 
 
textBoxField.Text = "Syncfusion"; 
 
textBoxField.Bounds = new RectangleF(0, 0, 100, 20); 
 
textBoxField.ToolTip = "First Name"; 
 
//Add the form field to the document. 
document.Form.Fields.Add(textBoxField); 
 
MemoryStream stream = new MemoryStream(); 
document.Save(stream); 
 
Please let us know If you need further assistance in this. 
 
Regards, 
Sasi Kumar S. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;