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. Image for the cookie policy date
close icon

Euro sign culture setting in PdfDocument

Hi,

In my app I use PdfGrid's to show text in a pdf file. In the cells I also must add text with a culture currency like:

            var pdfGridParagraph3 = new Syncfusion.Pdf.Grid.PdfGrid();
            pdfGridParagraph3.Columns.Add(1);
            pdfGridParagraph3.Columns[0].Width = 200;
            var pdfGridRowParagraph3Details1 = pdfGridParagraph3.Rows.Add();
            pdfGridRowParagraph3Details1.Cells[0].Value = "€ 200.000";

Unfortunetly the Euro sign is not visible in the created pdf file.

Do you have a solution?

9 Replies

KC Karthikeyan Chandrasekar Syncfusion Team November 12, 2018 05:06 AM UTC

Hi Vince, 
By default PdfGrid uses Standard Font to draw the text in the PDF document. As Euro is a Unicode character we have to use True Type font to get this supported. Please use the below code snippet to get this issue resolved. 
Stream fontStream = typeof(MainPage).GetTypeInfo().Assembly.GetManifestResourceStream("Sample.Assets.Arial.ttf"); 
pdfGridParagraph3.Style.Font = new PdfTrueTypeFont(fontStream, 14); 
Note: The TTF file should be placed in the Xamarin application. 

Revert me back if you need further assistance in this. 
Regards, 
Karthikeyan  



VI Vince November 12, 2018 08:15 AM UTC

Hallo Karthikeyan,

I saw this code snipped before but was not able to implement it.

Do you have a working example for Xamarin Android?

Best regards,

Vince


KC Karthikeyan Chandrasekar Syncfusion Team November 12, 2018 10:29 AM UTC

Hi Vince, 
Please find the simple sample below. 
Regards, 
Karthikeyan  



VI Vince November 12, 2018 11:51 AM UTC

Hallo KarthikeyanC,

I see that I was missing the reference "using System.Reflection;" in my app. 

But still it is not working because your code line "Stream fontStream = typeof(MainActivity).GetTypeInfo().Assembly.GetManifestResourceStream("GettingstartedAndroid.Assets.Arial.TTF");" returns the next error:

Unhandled Exception:
System.ArgumentNullException: Value cannot be null.
Parameter name: fontStream

Do you know what is going wrong?

Best regards,

Vince
p.s. the file "Arial.TTF" is available in the map Assets of my app.


KC Karthikeyan Chandrasekar Syncfusion Team November 13, 2018 12:44 PM UTC

Hi Vince, 
Thank you for your update. 
We are suspecting the font file (arial.ttf) build action is not set as Embedded Resource. So, the font stream becomes null and the null reference exception throws when try to accessing. 

Kindly check, step 7 from below KB to mark the font file as Embedded Resource. 

Please try our suggestion and let us know If you need further assistance in this. 
Regards, 
Karthikeyan  



VI Vince November 13, 2018 01:21 PM UTC

Hi KarthikeyanC,

I changed the Build Action of the file Arial.ttf to Embedded Resource as you mentioned. Unfortunetly the error (null reference for fontStream) is still there.

Do you have another tip?


KC Karthikeyan Chandrasekar Syncfusion Team November 14, 2018 03:59 PM UTC

Hi Vince, 
Thank you for your update. 
Can you please confirm, is the sample which we have provided on November 12, 2018 10:29 AM UTC in the forum is it working fine in your end?. The stream for the Arial.ttf font file can be retrieved using below code snippet. 
 
Stream fontStream = typeof(MainActivity).GetTypeInfo().Assembly.GetManifestResourceStream("GettingstartedAndroid.Assets.Arial.ttf"); 
 
 
 
Please find the font file path of GetManifestResourceStream parameter 
GettingstartedAndroid  - Name of the sample 
Assets                            - Folder name 
Arial.ttf                          - Font file name 
 
 
Make sure the GetManifestResourceStream parameter set properly. 
Regards, 
Karthikeyan 



VI Vince November 14, 2018 04:34 PM UTC

Hi KarthikeyanC,

Unfortunetly not. 

The GetManifestResourceStream is set with the correct namespace although it is already available in my class.

I also can not run your sample because I get an error (not enough memmory available).

So I still have no Euro sign in my pdf report.

Best regards,

Vince.




KC Karthikeyan Chandrasekar Syncfusion Team November 15, 2018 09:45 AM UTC

Hi Vince, 
We have created a new incident for further followup in this issue, can we have a web meeting to address this issue. Please follow the incident which is created under your account to get further information. 

Regards, 


Loader.
Live Chat Icon For mobile
Up arrow icon