I convert generated PDF report to byte array like below :
Code: Select all
public byte[]? GenerateInvoiceReport(string? Invoice_ID)
{
byte[]? pdfBytes = null;
StiReport? taxInvoice = LoadReportFromDatabase("Tax Invoice");
if (taxInvoice != null && Invoice_ID != null)
{
taxInvoice.RequestParameters = false;
//Set invoice id
taxInvoice.Dictionary.Variables["Invoice_ID"].Value = Invoice_ID;
//Render report with new value
taxInvoice.Render();
// Export to PDF as byte[]
using (var stream = new MemoryStream())
{
taxInvoice.ExportDocument(StiExportFormat.Pdf, stream);
pdfBytes = stream.ToArray();
}
//StiReportResponse.PrintAsPdf(taxInvoice); //Prints as PDF
//StiReportResponse.ResponseAsPdf(taxInvoice); //Downloads file as PDF
}
return pdfBytes;
}
I tried uisng stiReport.LoadDocument but it throws error as it's not stimulsoft report and is pdf.