I would like to call an action on a controller. Have the controller get the data from the model. The view then runs and generates a PDF. The only example I have found i
our final answer to this problem was to use Rotativa.
It wraps up the WKhtmltopdf.exe like some of the other solutions, but it's by far the easiest to use that I have found
I went and up voted all the other answers that also solve the problem well, but this is what we used to solve the problem posed in the question above. It is different from the other answers.
Here is a Rotativa Tutorial.
after you install it, this is all your need
public ActionResult PrintInvoice(int invoiceId)
{
return new ActionAsPdf(
"Invoice",
new { invoiceId= invoiceId })
{ FileName = "Invoice.pdf" };
}
Very Very simple.