【问题标题】:What is the best browser printing library, plugin, or snippet for javascript / jquery?javascript / jquery 的最佳浏览器打印库、插件或片段是什么?
【发布时间】:2010-11-24 15:29:20
【问题描述】:

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

【问题讨论】:

标签: javascript jquery printing printing-web-page


【解决方案1】:

看看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 });

【讨论】:

  • 这是我用过的一个工具,非常强大。
【解决方案2】:

我只是在看PrintArea's source,它似乎确实考虑了多个样式表。如果您告诉我们您对这些库的哪些方面不满意,将会有所帮助。

另外,我不确定使用纯 JS 解决方案比使用 PrintArea 之类的插件能够完成多少工作。

【讨论】:

  • 通过 JS-only 作为一个选项,我只是不希望在解决方案中引入一些其他库,如原型.js 等。对于其他功能,我一直在寻找更多选项,可能是格式,可能是报表的表格布局功能,或者更多与用户对话有关打印作业的选项的 UI 功能。只是更强大的东西。
猜你喜欢
  • 2022-11-01
  • 2011-05-17
  • 1970-01-01
  • 2010-10-09
  • 2012-02-18
  • 2011-06-11
  • 1970-01-01
  • 2011-06-16
  • 1970-01-01
相关资源
最近更新 更多