I have a web program that dynamically creates a pdf, when a user clicks on the print command in a data grid view, the pdf is created in the page printpdf.aspx. and then the following code is executed:
function printpdf()
{
var printWindow = window.open('printpdf.aspx', '', 'height=100,width=200');
checkLoad();
printWindow.focus();
printWindow.print();
printWindow.close();
}
this code is being executed and I get a print dialog box and the form closes on either ok or cancel, however the pdf is not yet generated when this code is triggered. I need a way to wait for page load. or a timer function that would work. I am also using this in multiple browsers. I have tried a timer function with no luck and the onload function.
checkLoad();
function checkLoad()
{
if (printWindow.onLoad)
{
printWindow.focus();
window.print();
window.close();
}
else
{
setTimeout('checkLoad();', 1000)
}
}