Articles in this section
Category / Section

How to export Middle Eastern Languages (Arabic, Hebrew) from SfDataGrid to PDF ?

5 mins read

SfDataGrid exports the data to PDF by using Syncfusion PDF component. By default, exporting Middle Eastern Languages (Arabic, Hebrew) are not supported in PDF. You can refer here to know about exporting the Middle Eastern Languages to PDF.

By using CellsExportingEventHandler in PdfExportingOptions, you can customize each cell when exporting into PDF and refer here to know about PdfExportingOptions.

In general, Arabic language is written from right to left. Here, Arabic languages are displayed in SfDataGrid from right to left as follows.

Figure 1: Arabic text in SfDataGrid

By default, Arabic languages in SfDataGrid are exported as left to right in PDF. You can export the Arabic language as displayed in SfDataGrid (export from Right to Left) by enabling RightToLeft property in PdfStringFormat and apply the format to the PdfGridCell by using CellsExportingEventHandler.

You can refer to the following code example to customize each cell when exporting SfDataGrid into PDF by using CellsExportingEventHandler.

C#

var options = new PdfExportingOptions();
//CellsExprotingEventHandler - used to handle or customize the cell.
options.CellsExportingEventHandler = GridCellPdfExportingEvent;
var document = this.datagrid.ExportToPdf(options);
public void GridCellPdfExportingEvent(object sender, GridCellPdfExportingEventArgs args)
{
    if (args.CellType == ExportCellType.RecordCell)
    {
        PdfStringFormat format = new PdfStringFormat();
        //format the string from right to left.
        format.RightToLeft = true;
        args.PdfGridCell.StringFormat = format;
    }
}

 

The following screenshot displays the Arabic text exported to PDF in right to left format.

Figure 2: Arabic text exported to PDF

You can refer to the sample from the following location.

Sample link: FlowDirectionExportPDF_WPF

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied