What is the best browser printing library, plugin, or snippet for javascript / jquery?
I'm trying to print a section of a web page and there are multiple css files, and several of those files contribute to the "print" media type. Some of the plugins I've seen assume that you only have one media="print" css file and that's all it needs. I have looked at PrintArea and jsprint and am not very impressed by either of them, I believe I can tweak them to get what I need, but I'm hoping there is a better library out ther开发者_高级运维e that I have yet to discover.
Have a look at printThis. It comes loaded with several options, such as load 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
});
I was just looking at PrintArea's source, and it seems that it does take into account multiple stylesheets. It would help if you told us what exactly you don't like about the libraries.
Also, I'm not sure how much more you'll be able to accomplish with a JS-only solution than the a plugin such as PrintArea already does.
精彩评论