我们有一个“导出为 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"
};
}