Euro symbol (€) in .NET Core MVC application

Hello,

I'm trying to export to PDF. I am not able to export the euro symbol (€) to my document.


On the internet, and in the forum i can find this example:
     //Create a new PDF true type font. 
     PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial", 12, FontStyle.Regular), true); 
 
     //Draw the Unicode text 
     page.Graphics.DrawString("€", font, PdfBrushes.Black, new PointF(10, 10)); 

However, this does not seem to work (syntax error).

I also see some examples where i need to copy the ttf file to my solution and take it as a stream from there, but i cannot imagine this is the way to go.

I'm using the latest Syncfusion version.

Kind regards.




2 Replies 1 reply marked as answer

SL Sowmiya Loganathan Syncfusion Team December 23, 2020 01:31 PM UTC

Hi Roel,   
  
Thank you for contacting Syncfusion support.   
  
We have analyzed your requirement “Add Euro symbol in PDF document in ASP.NET Core platform” and we can achieve this by using the below code snippet.   
  
//Load the TrueType font from the local *.ttf file  
FileStream fontStream = new FileStream("Arial.ttf", FileMode.Open, FileAccess.Read);  
PdfFont font = new PdfTrueTypeFont(fontStream, 14);  
  
//Draw the text  
graphics.DrawString("€", font, PdfBrushes.Black, new Syncfusion.Drawing.PointF(0, 0));  
  
  
Note: The provided code only works in base platforms like WF, WPF and ASP.NET.   
  
Please try the above sample in your end and let us know the result.   
  
Regards,  
Sowmiya Loganathan  
 


Marked as answer

JM Jesús Mostajo March 29, 2022 05:36 PM UTC

Hi friends,


I have tested wit net core .NET 5 and it works fine to show Euro symbo ! The font file has been upload under wwwroot/font


 string helveticaFontPath = string.Format("{0}{1}", _environment.WebRootPath, @"\font\Helvetica.ttf");
 FileStream fontStream = new(helveticaFontPath, FileMode.Open, FileAccess.Read);


Regards

Jesús Mostajo


Loader.
Up arrow icon