1

I am displaying a pdf file in by using iframe. I need to prine that pdf file only from that page. I have written below script for printing on button click.

//print pdf file
    $("#btnPrint").click(function () {      
        window.frames["printf"].focus();
        window.frames["printf"].print();
    });

Its working fine in chrome. But giving error in firefox and IE. In firefix, giving error like :Error: Permission denied to access property 'print'

In IE, giving error like: SCRIPT65535: Invalid calling object

I am not using any plugin for it. Please let me know how can i able to fix the issue?

akeeseth
  • 845
  • 2
  • 15
  • 32

1 Answers1

-1

Here I suggest you to pass div ID to this given function, It will help you to print the content of that div.

function PrintSummary(tableid) {

var tbl = document.getElementById(tableid);
if (tbl) {

    strPrintContent += tbl.innerHTML;

    var printWin = window.open("print.html", "printSpecial");
    printWin.document.open();
    printWin.document.write(strPrintContent);
    printWin.document.close();
    printWin.print();
}

}

DK Chauhan
  • 194
  • 1
  • 11
  • print.html, i do not want to open it in another window. the iframe is opening in popup. And want to print from there only without preview. – akeeseth Sep 18 '13 at 11:47
  • give it a try, It will not open another window, "print.html" is a page will be genrated on fly by java script and after showing printer setting and print button click it will be closed automatically. believe it will help you. I suggest you not to use iframe – DK Chauhan Sep 18 '13 at 13:06
  • iframe is my requirement, i have not used it for print. I have tried your solution. Its opening new tab for print with NaN page – akeeseth Sep 19 '13 at 05:22