简体   繁体   中英

Crystal report to send report directly to default printer

I'm trying to send a report direct to the default printer and this is already running ok with this code:

doc.Load(Server.MapPath("~\\reports\\CrystalReport\\DocumentCRV.rpt"));
doc.SetDataSource(dsReport);
doc.PrintToPrinter(1, true, 0, 0);

The problem is that it only works when i'm running the webapplication on my dev machine (so, i'm assuming that it's getting the default printer for the server, not the user's printer)

Does the user have a default printer set up? Also, this article might help:

Choosing a printer when printing from Crystal Reports in C#

There is no way to directly print to the users printer from the web server, unless possibly you are on the same internal network / directory. That would be a management nightmare.

Your best bet would be to pop open the viewer and then the print dialog.

I did use a active x control that could enumerate the end users printers and then automatically print it. However, it was IE only and poorly maintained.

Controling user printers is not something that can be done from server-side code, as this would create potential security holes. The browser can be forced to print in JavaScript. Perhaps you could have the report be downloaded to the user? Then they can print from within a PDF viewer or something?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM