Click here to Skip to main content
15,887,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to take print out of pdf file from iframe container tag of HTML page:
using IE 10 Browser I have tried by following Javascript in classic asp page

document.frameToPrint.focus();
document.frameToPrint.print();

window.frames["frameToPrint"].focus();
window.frames["frameToPrint"].print();

Both are not working in IE 10 for me.

I got this error: Unable to get property 'click' of undefined or null reference.
how i can solve this please help me ...
Posted
Updated 18-Jun-13 2:53am
v3

1 solution

Hello,

Below is a small test harness. See if that helps.
HTML
<!DOCTYPE html>
<html>
<head>
<title>Test PDF Print</title>
<script type="text/javascript">
var t;
function startPrint() {
    t = window.setTimeout(printPdf, 100, "JavaScript");
}
function printPdf() {
    window.clearTimeout(t);
    var f = document.frames ? document.frames['pdfFrame'] : document.getElementById('pdfFrame');
    var iw = f.contentWindow || f;
    iw.focus();
    iw.print();
    return false;
}
</script>
</head>
<body onload="startPrint()">
    <iframe id="pdfFrame" name="pdfFrame" src="docs/events.txt" width="100%" height="160"></iframe>
</body>
</html>

Note : The browser must have a PDF plugin installed and shlould be able to open pdf document inside, else it won't work

Regards,
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900