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.
Unfortunately, activation email could not send to your email. Please try again.

PdfDocument UTF8 Character

Thread ID:

Created:

Updated:

Platform:

Replies:

130846 Jun 7,2017 01:12 AM Jun 20,2017 08:32 AM Xamarin.iOS 5
loading
Tags: PDF
Balasubramanian Ramanathan
Asked On June 7, 2017 01:12 AM

I am using pdflightable in pdfdocmenr and set the font as
new PdfStandardFont(PdfFontFamily.Helvetica, 14, PdfFontStyle.Regular);
and when i export the pdf utf8 characters are blank, for example it does not export chinese characaters.
How to make the font support utf8 characters
Regards

Gayathri Ramalingam [Syncfusion]
Replied On June 8, 2017 10:36 AM

Hi Balasubramanian, 
Thank you for using Syncfusion product. 
We were able to reproduce the reported issue “Chinese character has not been preserved when we draw the PdfLighttable on PDF page”. Please find the code snippet and screen shot from below and conform to us whether you are facing same issue or not. 
Input XML file: 
<Products> 
    <Description1>111</Description1> 
    <Description2></Description2> 
    <Description3>III</Description3> 
  </Products> 
 
Code Snippet: 
 
// Create a new PDF document. 
 
PdfDocument doc = new PdfDocument(); 
 
//Add a page. 
 
PdfPage page = doc.Pages.Add(); 
 
//Acquire page's graphics. 
 
PdfGraphics graphics = page.Graphics; 
 
//Declare a PdfLightTable. 
 
PdfLightTable pdfLightTable = new PdfLightTable(); 
 
pdfLightTable.DataSource = //Get the data from Input XML file. 
 
pdfLightTable.Style.DefaultStyle = new PdfCellStyle(); 
 
pdfLightTable.Style.DefaultStyle.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 12f); 
 
//Draw the PdfLightTable. 
pdfLightTable.Draw(page, PointF.Empty); 
 
//Save the document. MemoryStream stream = new MemoryStream(); 
 document.Save(stream); 
 document.Close(true); 
 
if (stream != null) 
{ 
SaveiOS iosSave = new SaveiOS(); 
iosSave.Save("Output.pdf", "application/pdf", stream); 
} 
 
Please find the output document from the following link for your reference. 
 
Please let us know if you need further assistance on this. 
 
With Regards, 
Gayathri R 
 


Balasubramanian Ramanathan
Replied On June 16, 2017 09:14 AM

Hi,

Sorry for the late reply. Some how i did not get the notification for this thread.

I am doing the same thing as you have given in the sample code and having the same kind of result.

Is there a way to fix this?

Thank You

Gayathri Ramalingam [Syncfusion]
Replied On June 19, 2017 08:39 AM

Hi Balasubramanian,   
 
Thank you for your update. 
 
We could not draw UTF-8 characters using the PdfStandardFont, instead we can draw the UTF-8 by using PdfTrueTypeFont. The TTF file should be added to the project reference and inject the TTF stream via the PdfTrueTypeFont constructor. Using the below code you can get the stream value from .ttf file and you can set those font stream value to Font value of PdfLighttable. 
 
Please find the code snippet from below, 
Input XML file:  
<Products>     
    <Image>PDF</Image> 
    <Description>Essential PDF我我我我</Description> 
</Products> 
  
Code Snippet:  
  
// Create a new PDF document.  
  
PdfDocument doc = new PdfDocument();  
  
//Add a page.  
  
PdfPage page = doc.Pages.Add();  
  
//Acquire page's graphics.  
  
PdfGraphics graphics = page.Graphics;  
  
//Declare a PdfLightTable.  
  
PdfLightTable pdfLightTable = new PdfLightTable();  
  
pdfLightTable.DataSource = //Get the data from Input XML file.  
  
pdfLightTable.Style.DefaultStyle = new PdfCellStyle();  
 
Stream fontStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("jhenghei.ttf"); 
 
PdfTrueTypeFont font = new PdfTrueTypeFont(fontStream, 12); 
  
pdfLightTable.Style.DefaultStyle.Font = font;  
  
//Draw the PdfLightTable.  
pdfLightTable.Draw(page, PointF.Empty);  
  
//Save the document. MemoryStream stream = new MemoryStream();  
 document.Save(stream);  
 document.Close(true);  
  
if (stream != null)  
{  
SaveiOS iosSave = new SaveiOS();  
iosSave.Save("Output.pdf""application/pdf", stream);  
}  
  
 
Please find the output document from the following link for your reference.  
 
Please let us know if you need further assistance on this.  
  
With Regards,  
Gayathri R  
 
 
 


Balasubramanian Ramanathan
Replied On June 19, 2017 09:01 PM

Thank you for the reply. The specified font works for chinese characters.

Is there any open source TTF font thats support all the languages?

Thank You

KarthikeyanC [Syncfusion]
Replied On June 20, 2017 08:32 AM

Hi Balasubramanian, 
Thank you for your information, you may get more details about the open source true type fonts and its supported languages from the below link. 

Karthikeyan.C 


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.

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.

;