安装Greasemonkey插件并使用下面给出的脚本。
我修改了我在这里找到的脚本http://www.netsi.dk/wordpress/index.php/2011/07/07/printing-html-pages-make-screen-and-print-appear-the-same/
最后,我将“屏幕”更改为“打印”(我对jQuery一无所知,所以不要问我任何问题),以便实际上将屏幕版本发送给打印机。当打印为pdf时(使用Foxit或Nitro Pdf打印机),我在横向模式下将页面类型设置为Tabloid Extra,因此pdf大小或多或少与屏幕大小匹配。请享用!记住,我对编程一无所知,因此功劳归于原始作者。
// ==UserScript==
// @name Show print version (A Cross Browser Example) (showPrintVersion.user.js)
// @namespace netsi
// @match http://*/*
// @author Sten Hougaard
// @description Simply add #print to the URL. As descriped in my blog post (goo.gl/MEizV) this will activate any media=print stylesheets so that you can see the print version without printing
// ==/UserScript==
// a function that loads jQuery and calls a callback function when jQuery has finished loading
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js");
script.addEventListener('load', function () {
var script = document.createElement("script");
script.textContent = "(" + callback.toString() + ")();";
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
// the guts of this userscript
function main() {
var bPrint = (window.location.toString().indexOf('#print')!=-1);
if (bPrint) {
// The user wants to print this page
jQuery('link[media*="screen"]').attr('media', 'all'); // Enable the screen styling for all media types, including screen.
jQuery('link[media*="print"]').remove(); // remove any styling related to print
}
}
// load jQuery and execute the main function
addJQuery(main);
Delete This Node
。