Hi team,
Is this possible? I need to export List of sfQRCodeGenerator
(ex. productcode) via pdfexport of the sfgrid.
Beast regards,
Tyrone
Thanks Jeevakanth, will wait for it :)
|
@using Syncfusion.Blazor.Grids
<SfGrid ID="Grid" @ref="DefaultGrid" DataSource="@Orders" Toolbar="@(new List<string>() { "PdfExport" })" AllowPdfExport="true" AllowPaging="true">
<GridEvents PdfQueryCellInfoEvent="PdfQueryCellInfoHandler" OnToolbarClick="ToolbarClickHandler" TValue="Order"></GridEvents>
<GridColumns>
<GridColumn HeaderText="Image">
<Template>
@{
<span>Your image here</span>
}
</Template>
</GridColumn>
…
</GridColumns>
</SfGrid>
@code{
string bs = "/9j/3Jf1DDo+UWsjCXEqSve3………....AAAP/9k=";//This is the base64 string of the image
private SfGrid<Order> DefaultGrid;
public List<Order> Orders { get; set; }
public async Task ToolbarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args)
{
if (args.Item.Id == "Grid_pdfexport") //Id is combination of Grid's ID and itemname
{
PdfExportProperties ExportProperties = new PdfExportProperties();
ExportProperties.IncludeTemplateColumn = true;
await this.DefaultGrid.ExportToPdfAsync(ExportProperties);
}
}
public void PdfQueryCellInfoHandler(PdfQueryCellInfoEventArgs<Order> args)
{
if (args.Column.HeaderText == "Image")
{
//pass the base64 string as a parameter here
byte[] dataString = Convert.FromBase64String(bs);
System.IO.MemoryStream imageStream = new System.IO.MemoryStream(dataString);
args.Cell.Style.BackgroundImage = Syncfusion.PdfExport.PdfImage.FromStream(imageStream);
args.Cell.ImagePosition = Syncfusion.PdfExport.PdfGridImagePosition.Center;
}
}
|
thanks Jeevakanth SP for the update. I'll give it a try. :)