Export DataGrid to PDF header and missing diacritics

Hi,
I have a problem with diacritic at export to PDF. I have a diacritic in the header (in my case is letter 'č'), but if I export Datagrid to PDF the letter is missing. If I export to Excel everything is OK. As attached picture.

Next question: In my Datagrid is the background of header gray, but after export (PDF and Excel) is header white. How to get color to export file?

Attachment: MissingLetterCode_6e362821.zip

5 Replies

KK Karthikraja Kalaimani Syncfusion Team March 2, 2020 12:54 PM UTC

Hi Tomas,

Thank you for contacting Syncfusion support.

Regarding “I have a diacritic in the header (in my case is letter 'č'), but if I export Datagrid to PDF the letter is missing

To overcome this issue set the Diacritic font to PdfGridCell.Style.Font on Cell Exporting event. For more details please refer to the UG link and code snippet.

Code Example, 
[C#]
private void Button_Clicked(object sender, EventArgs e) 
        { 
            DataGridPdfExportingController pdfExport = new DataGridPdfExportingController(); 
           Stream fontStream = typeof(MainPage).GetTypeInfo().Assembly.GetManifestResourceStream("DataGridDemo.Amiri-Regular.ttf"); 
           pdfTrueTypeFont  = new PdfTrueTypeFont(fontStream, 5); 
             
            DataGridPdfExportOption option = new DataGridPdfExportOption(); 
            option.ApplyGridStyle = true; 
            option.FitAllColumnsInOnePage = true; 
            
 
            pdfExport.CellExporting += PdfExport_CellExporting; 
                       MemoryStream stream = new MemoryStream(); 
            var exportToPdf = pdfExport.ExportToPdf(this.dataGrid, option); 
            exportToPdf.Save(stream); 
            exportToPdf.Close(true); 
             
           Xamarin.Forms.DependencyService.Get<DataGridDemo.ISaveWindows>().Save("DataGrid.pdf", "application/pdf", stream); 
        }


….
private void PdfExport_CellExporting(object sender, DataGridCellPdfExportingEventArgs e)
 
        { 
            if (e.CellType == ExportCellType.HeaderCell) 
            { 
                e.PdfGridCell.Style.Font = pdfTrueTypeFont; 
            } 
        }
….. 

UG link :  https://help.syncfusion.com/file-formats/pdf/working-with-text?cs-save-lang=1&cs-lang=uwp#draw-text-using-truetype-fonts

Sample link : https://www.syncfusion.com/downloads/support/directtrac/general/ze/DataGridDemo-809778746.zip


Regarding “In my Datagrid is the background of header gray, but after export (PDF and Excel) is header white. How to get color to export file?

Your requirement can be achieved by enabling the ApplyGridStyle of the
DataGridPdfExportOption. For more details please refer to the below UG link.

UG link :
https://help.syncfusion.com/xamarin/datagrid/export-to-pdf#applying-styles-while-exporting

Regards,
Karthik Raja





TT Tomas Turek March 2, 2020 05:35 PM UTC

Thank you. It works perfectly.


KK Karthikraja Kalaimani Syncfusion Team March 3, 2020 05:26 AM UTC

Hi Tomas,

Thanks for the update.  
  
We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you.  

Regards,
Karthik Raja 



AK asim khan August 17, 2021 10:22 AM UTC

Learn how to export gridview to a pdf file using iTextSharp. ... through the Kendo MVC library) automatically splits and/or uses data annotations for the header text. ... PDF Export last row height is greater than the other rows; Spreadsheet PDF Export has missing borders; ... Some accents are replace by the empty symbol.



KK Karthikraja Kalaimani Syncfusion Team August 18, 2021 12:58 PM UTC

Hi Asim Khan,

Thanks for the update.

We need some information related to the reported issue. Can you please share us below things? 
 
  1. Provide code snippets related to SfDataGrid.
  2. Provide SfDataGrid version.
  
It will be helpful for us to check on it and provide you the solution at the earliest.  
 
Regards,
Karthik Raja

Loader.
Up arrow icon