public async Task GetPdf(DataSourceRequest dataSourceRequest, bool allPages, bool useExcelGeneration) { if (allPages) { dataSourceRequest.PageSize = 0; dataSourceRequest.Skip = 0; // for virtualization } IQueryable <WeatherForecast> queriableData = await MyDataService.GetForecasts(); var pdfExporter = new PdfExporter(); byte[] fileData = null; if (useExcelGeneration) { fileData = await pdfExporter.ExportWithRadSpreadProcessing(queriableData, dataSourceRequest); } else { fileData = await pdfExporter.ExportWithRadPdfProcessing(queriableData, dataSourceRequest); } string base64File = Convert.ToBase64String(fileData); //you can write the generated file to the file system to troubleshoot downloading issues //System.IO.File.WriteAllBytes("C:\\temp\\test.pdf", fileData); await jsRuntime.InvokeVoidAsync("saveFile", base64File, "application/pdf", "TelerikGridExport.pdf"); }
private async Task <string> GenerateFile(bool useExcel, DataSourceRequest gridRequest) { IQueryable <WeatherForecast> queriableData = await MyDataService.GetForecasts(); var pdfExporter = new PdfExporter(); byte[] fileData = null; if (useExcel) { fileData = await pdfExporter.ExportWithRadSpreadProcessing(queriableData, gridRequest); } else { fileData = await pdfExporter.ExportWithRadPdfProcessing(queriableData, gridRequest); } string base64File = Convert.ToBase64String(fileData); //you can write the generated file to the file system to troubleshoot downloading issues //System.IO.File.WriteAllBytes("C:\\temp\\test.pdf", fileData); return(await Task.FromResult(base64File)); }