We have implemented an "export to PDF" feature that generates a detailed report when the button is clicked. The PDF generation process is powered by Rotativa. While the PDF is being generated, we want to display a message (which is easy), and then dismiss it once the PDF is ready (which is proving to be challenging). Unfortunately, there doesn't seem to be any built-in hooks in the ViewAsPdf() method that would allow us to automatically dismiss the message after the PDF has been generated. Has anyone encountered this issue before? What solutions or workarounds did you use?
I am currently trying to figure out how to hide the message after the PDF generation process is complete.
Thank you in advance for any assistance.
The Message Displayed in the View
<!-- This is the message displayed to users 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 Function for Handling Button Click
// This function displays the message when the export to PDF button is clicked
<script type="text/javascript">
$("#export-pdf-btn").click(function () {
$('#pdfProcessing').show();
});
</script>
Controller Action for Exporting to PDF
// Controller action handler for exporting to PDF
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"
};
}