What is the best way to show a message ("the pdf is generating...") while the pdf is creating ans loading?
Thanks, Ims
message while load?
Re: message while load?
Support · Nov 7, 2006Hello Ims,
Since the content type of the PDF's page must be "application/pdf", the only way to accomplish this is to create the PDF behind the scenes and then redirect the browser to the PDF once it is created. This would require you to save the PDF to disk or store the PDF in memory so that it can be displayed on redirect.
Thanks,
ceTe Software Support Team
Re: message while load?
Forum member · Nov 7, 2006
Can you post a single example (c#) to create a PDF in this way (create the PDF behind the scenes and rederict it) ?
Thanks
Ims
Re: message while load?
Support · Nov 7, 2006Hello Ims,
Sure, we'll work on that and post it here once it's ready.
Thanks,
ceTe Software Support Team
Re: message while load?
Support · Nov 9, 2006Hello Ims,
Here is a good solution. You just need to create a new ASPX page to act as the page to show while waiting for the PDF to generate. The example below takes a URL variable so that it can be used for multiple pages. Just put the destination page in a "destPage" URL variable, and the page below will display until that page is ready.
Here is the contents for the waiting page. Place this directly below your @Page directive line and remove the other content:
<HTML>
<HEAD>
<title>Building report, please wait...</title>
<script>
var ctr = 1;
var ctrMax = 50; // how many is up to you-how long does your end page take?
var intervalId;
function Begin()
{
//set this page's window.location.href to the target page
window.location.href = "<%= Request.QueryString["destPage"]%>";
// but make it wait while we do our progress...
intervalId = window.setInterval("ctr=UpdateIndicator(ctr, ctrMax)", 500);
}
function End()
{
// once the interval is cleared, we yield to the result page (which has been running)
window.clearInterval(intervalId);
}
function UpdateIndicator(curCtr, ctrMaxIterations)
{
curCtr += 1;
if (curCtr <= ctrMaxIterations)
{
indicator.style.width =curCtr*10 +"px";
return curCtr;
}
else
{
indicator.style.width =0;
return 1;
}
}
</script>
</HEAD>
<body onload="Begin()" onunload="End()">
<form id="Form1" method="post" runat="server">
<div align=center><h3>Building report, please wait...</h3></div>
<table id=indicator border="0" cellpadding="0" cellspacing="0" width="0" height="20" align="center">
<tr><td align="center" bgcolor=red width="100%"></td></tr>
</table>
</form>
</body>
</HTML>
Thanks,
ceTe Software Support Team
Re: message while load?
Forum member · Nov 10, 2006Thanks for the help.
The code run right :)
Ims