Search code examples
c#asp.net-mvcrotativa

Preview pdf instead of download using Rotativa


I am trying to print .html file as .pdf file using Rotativa. I have tried this code:

return new ActionAsPdf("Index") { FileName = "Product.pdf" };

My index action is here:

public ActionResult Index()
{
    return View(db.Products.ToList());
}

But, the generated .pdf file is downloaded instead of previewed. I don't want to download it. I want the preview and then print it.


Solution

  • I got the answer.I need to remove the FileName attribute.If I want to download it, I need to add the FileName attribute and if I want to see just the preview, I need to remove this.The code should be just :

    return new ActionAsPdf("Index");