javascript/jquery 的最佳浏览器打印库、插件或代码段是什么?

vas*_*kin 0 javascript printing jquery printing-web-page

我正在尝试打印网页的一部分,并且有多个 css 文件,其中一些文件有助于“打印”媒体类型。我见过的一些插件假设你只有一个 media="print" css 文件,这就是它所需要的。我看过 PrintArea 和 jsprint 并且对它们中的任何一个都没有留下深刻印象,我相信我可以调整它们以获得我需要的东西,但我希望那里有一个我尚未发现的更好的库。

p8u*_*8ul 5

看看printThis。它加载了多个选项,例如加载 css。

$("#mySelector").printThis({ debug: false, // show the iframe for debugging importCSS: true, // import page CSS importStyle: false, // import style tags printContainer: true, // grab outer container as well as the contents of the selector loadCSS: "path/to/my.css", // path to additional css file - use an array [] for multiple pageTitle: "", // add title to print page removeInline: false, // remove all inline styles from print elements printDelay: 333, // variable print delay header: null, // prefix to html footer: null, // postfix to html base: false , // preserve the BASE tag, or accept a string for the URL formValues: true, // preserve input/form values canvas: false, // copy canvas elements (experimental) doctypeString: "...", // enter a different doctype for older markup removeScripts: false, // remove script tags from print content copyTagClasses: false // copy classes from the html & body tag });