html - Print PDF file with Javascript in all popular browser -


how print pdf file using javascript across popular browser? have done quite extensive research on question , there no real solutions.

first approach use iframe, however, iframe not practise. code listed following.

function printiframepdf(){     window.frames["printf"].focus();     try {         window.frames["printf"].print();     }     catch(e){         window.print();         console.log(e);     } } 

second approach use <embed> or <object>tag display pdf , use document.getelementbyid(pdfid).print() print. however, chrome not support function. code listed following.

function printobjectpdf() {     document.getelementbyid('idpdf').print(); } 

is there solution this?

did consider pdf.js?

https://mozilla.github.io/pdf.js/

this web standards-based platform.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -