Printing receipt ASP.NET

喜夏-厌秋 提交于 2019-12-21 06:28:48

问题


I'm currently making a project where I need to print out a receipt on a receipt printer. At the moment i'm using the CSS mechanism media=screen , media=print to indicate what to print.

Problem is of course the header and footer which can't be removed, as it is client browser specific.

So i'm wondering if anyone has another suggestion on how to do the printing. Preferbly without using too much IO.


回答1:


Generally speaking, if you need precise control, your best bet is to have a pdf, or other doocument format that is generated from the server, for your printing. (if the machines printing receipts are controlled, and have word, than .doc (html with an output type) is the easiest method. There are a number of third party controls for generating PDF from server-side code as well. Hope this leads you in a usable direction, since you didn't specify if you controlled the client machines in use.

One benefit to PDF is you can use it as a hard archive, as well as being able to email receipts as an attachment.




回答2:


The header and footer information (Assuming you're talking about the URL showing up at the bottom of a page) is client-side and there is nothing you can do to change that from server side.

If all of your printing is going to be done from inside your company, you could have a group policy created for Internet Explorer printing to remove these company-wide. You could also just have instructions on your page on how to change these setting manually.

Another option is to print with a 3rd party application, such as PDF, or print it directly from the server if that option is available to you.




回答3:


Do you mean the page header and footer?

If that's the case, wrap the header and footer in IDs and create CSS tags to target them and give them a much simpler styling, or you can use the CSS element display:none to remove them altogether in the print css.




回答4:


You could load the content you want to print into an iframe, focus on it, and print that. That way you'll have exact control over what appears on the receipt.

It'd take a small bit of javascript, but I've had success doing similiar things when I wrote a custom contract printer.




回答5:


It's not an ASP solution, but may help:

http://code.google.com/p/jzebra

It's a java plugin that can bypass the header and footer stuff.



来源:https://stackoverflow.com/questions/705379/printing-receipt-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!