I need to build automatic kiosk, where people will get their pdf's printed. I will use firefox with silent.print mode on, but I have trouble getting pdf to print in a page that will be a popup (so creating a popup will print pdf inside).
The thing is, that printing is printing white page because print occurs before pdf is loaded, so I tried adding function that will make printing wait. Results is the same, because waiting function will make generating pdf wait also.
Any ideas how to make this work or find workaround?
<!DOCTYPE html>
<html>
<head>
<title>Pdf Result</title>
</head>
<body>
<p>Loading resources....</p>
<-- loading pdf -->
<div>
<div>
<iframe onload="window.print()" id="pdf-js-viewer" src="lib/pdfjs/web/viewer.html?file=test.pdf" title="webviewer" frameborder="0" width="500" height="600"></iframe>
</div>
</div>
<script>
//making script wait
function wait(ms){
var start = new Date().getTime();
var end = start;
while(end < start + ms) {
end = new Date().getTime();
}
}
wait(5000);
//printing itself
document.getElementById("pdf-js-viewer").contentWindow.print();
</script>
</body>
</html>