c# - 使用 C# 和 Rotativa 生成 PDF 后删除状态消息

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

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

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

非常感谢

View 中的消息

<!-- 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>

Controller 操作

// 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"
    };
}

最佳答案

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

关于c# - 使用 C# 和 Rotativa 生成 PDF 后删除状态消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26124672/

相关文章:

asp.net - 在哪里存储加密 key MVC 应用程序

c# - Xamarin 表单 : how to implement platform specific code

css - 以一致的方式制作 compass 顺序 Sprite

jQuery 用不同的类替换特定模式的所有元素的类

html - 将绝对定位设置为左侧 :50%, 页面翻倍时

javascript - 在 javascript 中设置 Razor 变量

asp.net-mvc - 了解 MVC 模型

c# - 使用 FFMPEG 从音频文件中获取波形数据

c# - 使按钮打开超链接

c# - 当数字是字符串时比较数字