How do I print a pdf of this url in an iframe using a html print button
I tried two solutions using the answers from these threads:
My html is an iframe with the pdf url above and my js looks like:
<embed
type="application/pdf"
src="the url that is above. too long to fit here"
id="pdfDocument"
width="100%"
height="100%" />
<button id="printButton" onclick="javascript:printPage()"
>
My js:
function printPage(documentId) {
var doc = document.getElementById('pdfDocument');
//Wait until PDF is ready to print
if (typeof doc.print === 'undefined') {
setTimeout(function(){printPage(documentId);}, 1000);
} else {
doc.print();
}
}
I have not had any luck. The button is non-responsive. Something must be wrong with the js. They have a printjs library. Maybe that is a better route. Any suggestions appreciated. Thanks.