ASP.NET-直接在客户端打印 - 无需提示打印对话框 [英] ASP.NET-Printing on client's side directly - without prompting for a print dialogue box

查看:57
本文介绍了ASP.NET-直接在客户端打印 - 无需提示打印对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,



我正在使用.NET为visualpoint网站制作一个Web部件(visual studio 2010)。



我如何在我的网页部分添加一个按钮,点击它会打印存储在我服务器的c:驱动器上的.text文件


$ b $客户端的ba打印机没有提示打印对话框?



要打印的文件位于服务器的c:驱动器,其中托管共享点站点。



打印机将是连接到客户端计算机的本地打印机。



我使用过http://www.dotnetspider.com/resources/43366-Printing-Datatable-Data-In-C.aspx上的代码,用于创建



.text文件。



请建议。



提前致谢。

dear all,

I am making a Web Part for a sharepoint site with .NET (visual studio 2010).

How can I add a button in my web part, clicking on which will print a .text file stored on my server's c: drive to

a printer on the client side without prompting for a 'print' dialogue box?

The file to be printed is in the server's c: drive where the sharepoint site is hosted.

The printer will be a local printer attached to the client machine.

I have used the code at http://www.dotnetspider.com/resources/43366-Printing-Datatable-Data-In-C.aspx for creating

the .text file.

Please suggest.

Thanks in advance.

推荐答案

您无法更改浏览器的工作方式。但是,您应该知道您复制的代码不会全部工作,如果您更改了存储txt文件的文件夹,以便您的网站可以访问它,它将使用无论打印机连接到服务器。很明显,您不了解此代码或Web的工作原理。 C#代码在服务器上运行。测试时,服务器和客户端是相同的,但当有人查看您的页面时,它们不是。打印网页的唯一方法是在浏览器窗口中使用window.print(),显示您想要打印的内容,仅此而已。你不能到处找一个询问你要使用什么打印机的对话框。
You can't change how the browser works. However, you should know that the code that you've copied, will not work all, and if you change the folder it stores the txt file in, in order that your web site would have access to it, it will print your document using whatever printer is attached to the server. It's clear you don't understand this code, or how the web works. C# code runs on the server. When you test, the server and the client are the same, but when someone looks at your page, they are not. The only way to print a web page, is to use window.print() in a browser window that is showing what you want printed, and nothing more. You can't get around getting a dialogue box asking you what printer to use.


亲爱的所有



最后,我有解决了这个问题。



从链接http://stackoverflow.com/questions/3507187/how-to-print-a-pcl-制作.dll filr file-in-c。



将dll添加到GAC。



在我的代码中调用它.....和瞧.......它打印我的文本文件。



请注意我使用的是HP Laserjet P2015 PCL6。



......感谢您的宝贵指导。



...以及那些谁认为这是不可能的,请看看上面的链接。



再次谢谢大家!
Dear all

Finally, I have solved the problem.

Made a .dll filr from the link http://stackoverflow.com/questions/3507187/how-to-print-a-pcl-file-in-c.

Added the dll to the GAC.

Call it in my code.....and voila.......It prints my text file.

Note that I am using a HP Laserjet P2015 PCL6.

......Thanks to all for your valuable guidance.

...and for those who thought it was IMPOSSIBLE, take a look at the above link.

Thank you all again!


打印对话框提示是浏览器内置的安全功能,这样,当用户访问您的网站时,您不应该通过打印公司的披萨菜单来浪费用户的打印纸张... :)。您拥有该网站,而不是用户的打印机和纸张。让他决定是否打印。



无法禁用它,因为这是浏览器的工作方式。即使它可能被禁用(我不知道如何,但如果有人真的这样做),这将是一个安全漏洞或黑客,本论坛不提供任何代码或解决方案。
The print dialog prompt is a security feature built into the browsers so that you should not waste the users' printing paper by printing your company's pizza menus whenever the user visits your website ... :). You own the website, not the users' printer and the paper. Let him decide whether to print or not.

It cannot be disabled since this is how the browser works. Even if it could be disabled ( I don't know how, but if somebody really does ), it would be a security breach or hack for which this forum does not provide any code or solution.


这篇关于ASP.NET-直接在客户端打印 - 无需提示打印对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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