I am new asp .net .
I am using Rotativa to turn a Razor view into a PDF.
I am having a normal preview page which is working fine.
The same thing I want to print in PDF .
[HttpGet]
public ActionResult IdCardPreview(string empid)
{
int empid1 = Convert.ToInt32(empid);
var dataList = db.mstEmpInformations.Where(x => x.intEmpId == empid1).SingleOrDefault();
return View(dataList);
}
public ActionResult GeneratePDF(string empid)
{
int empid1 = Convert.ToInt32(empid);
return new Rotativa.ActionAsPdf("IdCardPreview", new { empid1 });
}
while running the generate pdf is is showing the error as Object reference not set to an instance of an object.
Can any1 tell how i can pass the empid from generate pdf to IDCardpreview ?
The code should look like this at the generatePDF Action.
public ActionResult GeneratePDF(string empid)
{
return new Rotativa.ActionAsPdf("IdCardPreview", new { empid = empid });
}
Rotavita is going into the IdCardPreview action itself, and the conversion from string to int will be at the IdCardPreview Action.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With