【问题标题】:Remove status message after PDF has been generated with C# and Rotativa使用 C# 和 Rotativa 生成 PDF 后删除状态消息
【发布时间】:2014-09-30 15:32:33
【问题描述】:

我们有一个“导出为 pdf”按钮,单击该按钮会生成一份冗长的报告。 PDF 使用Rotativa 生成。我们需要在生成 PDF 时显示一条消息(简单),并在生成 PDF 后将其关闭(困难)。我在 ViewAsPdf() 方法中看不到任何可以让我们在生成 PDF 后关闭消息的钩子。有没有人能够解决这个问题?有哪些钩子(如果有的话)?

我试图在生成 PDF 后隐藏消息。

非常感谢

视图中的消息

<!-- The message we show to the user after they click the export to PDF button -->
<div id="pdfProcessing" style="display: none; border:1px solid #666666;">
                <img src="@Url.Content("~/Content/images/logo.png")" alt="@Index.PdfProcessing ..." />
                <h2>@Index.PdfProcessing ...</h2>
                <div>@Index.PdfProcessingMessage</div>
</div>

Javascript 按钮点击处理程序

//Displays message when the export to PDF button is clicked
<script type="text/javascript">

    $("#export-pdf-btn").click(function () {

        $('#pdfProcessing').show();
    });
</script>

控制器动作

// Export to PDF button action handler
public ActionResult Pdf(string districtId, int year, int month)
{
    return new ViewAsPdf("Index", EducationReportTasks.BuildViewModel(User, districtId, year, month, true))
    { 
        FileName = districtId + "-" + year + "-" + month + "-report.pdf"
    };
}

【问题讨论】:

    标签: c# css asp.net-mvc-3 rotativa


    【解决方案1】:

    您应该使用 javascript 下载文件。也许你可以使用这样的东西:https://github.com/johnculviner/jquery.fileDownload

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-15
      相关资源
      最近更新 更多