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

Font Awesome in PDF documents

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

regards
Martin

3 Replies

SL Sowmiya Loganathan Syncfusion Team October 18, 2019 08:06 AM

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 
 



SL Stefan Limpert December 22, 2022 12:06 PM

Hello Sowmiya,

i also want to export a Grid with columns contains several FontAwesome icons. How can i achieve to export these icons with pdf export of Grid?

Regards

Stefan



RS Rajapandiyan Settu Syncfusion Team December 28, 2022 07:58 AM

Hi Martin,


Currently, The EJ2 Grid does not have support to export icons and custom elements. You can export images and hyperlinks from the Grid. Please find the below demo for your reference.


Demo: https://ej2.syncfusion.com/aspnetcore/Grid/DefaultExporting#/fluent


We logged a feature task for your requirement as Need to provide support for exporting grid with column template and Detail template and added it to our feature request database. At the planning stage for every release cycle, we review all open features and identify features for implementation based on specific parameters including product vision, technical feasibility, and customer interest. This feature will be included in any of our upcoming releases. 


Feedback Link: https://www.syncfusion.com/feedback/10384/need-to-provide-support-for-exporting-grid-with-column-template-and-detail


You can communicate with us regarding the open features any time using the above Feature Report page.  


Regards,

Rajapandiyan S


Loader.
Live Chat Icon For mobile
Up arrow icon