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

How to export the images that are loaded inside the GridTemplateColumn to PDF document?

SfDataGrid control exports the data to PDF using Syncfusion PDF Component. Generally, you can export the images to PDF document when the images are loaded inside the GridImageColumn.

You can also load the image by using GridTemplateColumn. The following screenshot illustrates the GridTemplateColumn “Pass/Fail” loaded with the corresponding images that is defined as a DataTemplate of that Column.

Figure 1 : SfDataGrid with image loaded in GridTemplateColumn

You cannot export the images to PDF document when it is loaded inside the GridTemplateColumn.

Therefore, you can achieve this by customizing and assigning the same images to the background of PDFGridCell while exporting, with the help of CellsExportingEventHandler delegate of PdfExportingOptions. Refer to the following code example.

C#

In the above code example, GridCellPdfExporting event handler is assigned to the CellsExportingEventHandler delegate and it is invoked while exporting each cell to PDF. Here, you can handle and customize each PdfGridCell while exporting and GridCellPdfExportingEvent contains the following argument as a parameter.

  1. Sender: The sender is SfDataGrid.
  2. GridCellPdfExportingEventArgs: It contains a set of properties that are used to customize the cell to PDF and some are as follows.
  • CellType: You can use this property to check the type of the exported cell.
  • CellValue: It contains the actual value that is to be exported to PDF.
  • ColumnName: Specifies the column name of the exporting cell.
  • PdfGridCell: Specifies the PdfGridCell to be exported and you can customize the Style, background, foreground and alignment etc., of a particular cell.

Here, you can access the images from the resource file and you can set them to the background of PdfGridCell style as illustrated in the following code example.

C#

The above GridTemplateColumn images are exported in to PDF document as displayed in the following screenshot.

Figure 2: PDF View

Sample Links:

WinRT

UWP

Article ID: Published Date: Last Revised Date: Platform: Control: .NET Framework: Product Version:
6009 01/19/2016 01/19/2016 UWP SfDataGrid 4.5 12.4.0.24
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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