【问题标题】:Preview pdf instead of download using Rotativa预览 pdf 而不是使用 Rotativa 下载
【发布时间】:2023-03-06 23:17:02
【问题描述】:

我正在尝试使用 Rotativa 将 .html 文件打印为 .pdf 文件。我试过这段代码:

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

我的索引操作在这里:

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

但是,生成的.pdf 文件被下载而不是预览。我不想下载它。我想要预览,然后打印出来。

【问题讨论】:

  • hmm,我认为 Rotativa 仅充当 pdf 转换器,但预览文件取决于您的浏览器是否具有 acrobat 阅读器或类似的工具,可让您在本地计算机上预览文档groupdocs.com/apps/viewer

标签: c# asp.net-mvc rotativa


【解决方案1】:

我得到了答案。我需要删除 FileName 属性。如果我想下载它,我需要添加 FileName 属性,如果我只想看到预览,我需要删除它。代码应该只是:

return new ActionAsPdf("Index");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-03-24
    • 2021-04-02
    • 2016-07-23
    • 2014-06-08
    • 2016-12-14
    • 2019-04-03
    • 2012-08-18
    相关资源
    最近更新 更多