How to print a pdf?

前端 未结 1 1798
不思量自难忘°
不思量自难忘° 2021-02-06 18:09

I have a pdf url, embedded in a rectangular area of an iframe. I am trying to print it on click of a button . My code looks like this :

JavaScript to print :

相关标签:
1条回答
  • 2021-02-06 19:01

    Folks, just got a solution , which works fine for me .

    function printPage(htmlPage)
    {
        var w = window.open("about:blank");
        w.document.write(htmlPage);
        if (navigator.appName == 'Microsoft Internet Explorer') window.print();
        else w.print();
    }
    

    So, if it is MSIE, then we can just use : window.print();

    0 讨论(0)
提交回复
热议问题