Control Printing in ASP.NET Page
I need to create a web application that prints checks. Because of the nature of the program, it needs to be very secure, and each action needs to be logged. I need to be able to generate a check, print a check, allow reprints if needed, etc.
I've got the generation of the checks completed. I've decided to make a PDF (so that i don't get any browser header/footer garbage). What I'd like to do is not even save that PDF to a file but to instead send the data directly to a printer. Basically, I'd like for the user to enter the amount of the check, select which account it's going to be printed for, then click a button that sends the data for that check directly to the printer. I don't even want the user to be able to view the PDF of what's to be printed.
Has anyone done something similar to this in ASP.NET?
Thanks.
[EDIT]
The original question I asked was answered with ActiveX controls. I, however, decided to do it a different way. Instead of printing a PDF, I've decided to create an image of the background of the check. I will then use that image (.jpg), and开发者_StackOverflow社区 manipulate it by placing the appropriate text (MICR line, amount, check date, etc.) on it using System.Drawing.Graphics and stored X,Y coordinates and font preferences in my DB. From there, I can use the System.Drawing.Printing namespace to send the new .jpg file to a network printer from the web server, eliminating the need for an activeX control and further tightening security because the new image of the finished check is never saved, and the user never has access to the overlay of the check.
Thanks for your help.
If you look at how postal services tackle this problem, you'll notice that a simple web application won't do. To have control over how and when items are sent to the printer, ActiveX compontents or Java software is used.
[Edit]
Small clarification: I ment that the software has to run on the client-side as opposed to your suggested server-side suggestion.
If you want to go the .NET route, you're down to an ActiveX in Managed C++ or a Click-Once application that is launched from the web (allows more of the .NET language, but can be decompiled and altered).
We have implemented this scenario in a couple of ways. First, we have the traditional PDF solution, where the server generates the PDF print image, returns it to the browser which is then displayed via the PDF plug-in and optionally printed.
Second, we wrote a client-side ActiveX component to handle the print. Pass the input values to a backend web service which uses FOP to format the print into PCL. The PCL is passed back to the ActiveX component who then sends the PCL directly to the users default printer. No PDF required here.
Either way works, but only the second option - which will require you to implement some client-side piece - meets all your requirements.
There isn't really a way to do this. You can only send a document to the user which the user can then send to the printer. There are ways to prompt the print dialogue to pop straight up, but the web would be pretty insecure if you were allowed to control how data was managed on the user's machine.
NKCSS is right that it would require software actually installed on the user's machine. You have done as much as you can by making it a PDF that the user is prompted to print.
If you had the cheque as html, you can used styles to show/hide content just for the printer as discussed in this post: here
There's no way to do this completely securely. Even if you force the PDF to print directly to the user's default printer, that itself could be a PostScript or PDF printer like PDFCreator. So they could still get a viewable PDF in the end.
精彩评论