如何强制网站打印 [英] How to force a website to print

查看:248
本文介绍了如何强制网站打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这听起来像一个奇怪的请求,但是...我有一个Web应用程序,设置为收集数据并定期将其存储到数据库中。应用程序的设计基本上始终保持打开状态,屏幕显示最近添加到数据库中的内容(通过使用ajax检查数据库并在有新内容时刷新页面)。我还需要创建一个打印输出,无论何时添加到数据库中。我目前有一个打印按钮,它强制打印对话框出现,并使用不同的样式表作为打印视图,但用户仍然需要按下打印按钮,然后在出现的对话框中按打印。有没有一种方法可以将程序完全自动化到网站将打印页面到默认打印机的位置,并绕过打印按钮和出现的对话屏幕?

编辑:我知道我可以做window.print();让打印对话框出现......我问我是否可以在没有任何人工输入的情况下使页面从打印机中出来。根据这些帖子,似乎只有网页浏览器才能完成。

解决方案

您可以编写一个具有Web浏览器控件的独立应用程序,并为您进行打印。尽管如此,在常规浏览器中没有办法做到这一点 - 考虑到这一点。


This is going to sound like an odd request, but... I have a web application that is set up to collect data and store it into a database on regular intervals. The application is designed to basically stay open all the time, and the screen displays what is most recently added into the database (by using ajax to check the database and refresh the page when there is something new). I also need to create a printout whenever something is added into the database as well. I currently have a print button, which forces the print dialogue box to come up and uses a different style sheet for a "print view" but the user is still required to press the print button, and then press print in the dialogue that comes up. Is there a way to fully automate the process to where the site will print the page to the default printer and bypass the print button and the dialogue screen that comes up?

Edit: I know I can do window.print(); to make the print dialog come up... I was asking if I can actually make a page come out of the printer with no human input. And based on the posts, it seems like it can't be done with just the web browser.

解决方案

You could write a separate application that has a web-browser control, and have it do the printing for you. There's no way to do it in a regular browser, though --- think of the implications of that.

这篇关于如何强制网站打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆