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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Font Awesome in PDF documents

Thread ID:

Created:

Updated:

Platform:

Replies:

148392 Oct 17,2019 03:40 PM UTC Oct 18,2019 01:06 PM UTC ASP.NET Core - EJ 2 1
loading
Tags: PDF
Martin
Asked On October 17, 2019 03:40 PM UTC

Is there any way of adding a font awesome character to a table cell ? or anywhere really.

regards
Martin

Sowmiya Loganathan [Syncfusion]
Replied On October 18, 2019 01:06 PM UTC

Hi Martin, 

Thank you for contacting Syncfusion support. 

We can achieve your requirement of “Add font awesome characters to a table cell” using the font file “fontawesome-webfont.ttf”. Please refer the below code snippet for more details, 

//Create a new PDF document 
PdfDocument document = new PdfDocument(); 
 
//Add a page 
PdfPage page = document.Pages.Add(); 
 
//Create font 
FileStream fontFileStream = new FileStream("fontawesome-webfont.ttf", FileMode.Open, FileAccess.Read); 
PdfFont font = new PdfTrueTypeFont(fontFileStream, 14); 
 
//Create a PdfGrid 
PdfGrid pdfGrid = new PdfGrid(); 
 
//Create a DataTable 
DataTable dataTable = new DataTable(); 
 
//Add columns to the DataTable 
dataTable.Columns.Add("Font Name"); 
dataTable.Columns.Add("Awesome Character"); 
 
//Add rows to the DataTable 
dataTable.Rows.Add(new object[] { "fontawesome-webfont", "\uf02d" }); 
 
//Assign data source 
pdfGrid.DataSource = dataTable; 
 
//Add cell style 
PdfGridCellStyle cellStyle = new PdfGridCellStyle(); 
cellStyle.Font = font; 
pdfGrid.Rows[0].Cells[1].Style = cellStyle; 
 
//Draw grid to the page of PDF document 
pdfGrid.Draw(page, new PointF(10, 10)); 
 
//Save the document 
MemoryStream stream = new MemoryStream(); 
document.Save(stream); 
document.Close(true); 


Please find the .ttf file downloaded link from below, 

Please try the above code snippet in your end and let us know the result. 

Regards, 
Sowmiya Loganathan 
 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon