Preview pdf instead of download using Rotativa

喜你入骨 提交于 2019-12-12 16:24:46

问题


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.


回答1:


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");


来源:https://stackoverflow.com/questions/31228407/preview-pdf-instead-of-download-using-rotativa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!