Hi,
I create a report and i try to export it to PDF, I'm using C# ASP.net MVC 4 , but an unknown error occured and I can't resolve it, can you help me please,
this is the C# Source code
and I the print screen of the generated PDF file in the attachements
public ActionResult PrintRpt(int myId)
{
try
{
myReport report = new myReport();
report.sqlDataSourceMyReport.Parameters[0].Value = myId;
report.sqlDataSourceMyReport.ConnectionString = "";
var processor = new ReportProcessor();
var res = processor.RenderReport("PDF", report, null);
var pdfSteream = new MemoryStream(res.DocumentBytes);
FileStream file = new FileStream("d:\\file.pdf", FileMode.Create, FileAccess.Write);
pdfSteream.WriteTo(file);
file.Close();
pdfSteream.Close();
byte[] bytes = pdfSteream.ToArray();
string base64String = string.Empty;
try
{
base64String = System.Convert.ToBase64String(bytes, 0, bytes.Length);
byte[] binaryData = System.Convert.FromBase64String(base64String);
}
catch (System.ArgumentNullException)
{
throw new Exception("Binary data array is null.");
}
return Json(base64String, JsonRequestBehavior.AllowGet);
}
catch (Exception e)
{
return Json(e, JsonRequestBehavior.AllowGet);
}
}