打印水晶报表时出错,并显示异常消息“未安装打印机”
我收到异常消息“未安装打印机”。同时打印我们网站的 depolyed 发布报告。
我使用 _rptDocument.PrintToPrinter(1, false, 0, 0); 打印报告。
我遇到了这个例外,即使我的机器上安装了不止一台打印机。 另外,我在开发过程中没有遇到这种异常,开发过程中一切都很顺利。
我使用“发布网站”和“Web 项目部署”选项来发布/部署网站,但得到了相同的结果。
有什么建议吗?
编辑
示例代码
DataSet dsResult = null;
rptDocument = new ReportDocument();
rptDocument.Load(Server.MapPath("WINGR0040.rpt"));
// Fetch report data.
...
rptDocument.SetDataSource(dsResult);
// Print report.
rptDocument.PrintToPrinter(1, false, 0, 0);
I got an exception with message "No printers are installed." while printing a report for depolyed release of our website.
I use _rptDocument.PrintToPrinter(1, false, 0, 0);
to print a report.
I got that exception, even I've more than one printer installed on my machine.
Also, I don't get that exception while development, everything while development is going fine.
I used "Publish Web Site" and "Web Project Deployment" options to publish/deploy website, but I got the same result.
Any suggestions?
Edit
Sample Code
DataSet dsResult = null;
rptDocument = new ReportDocument();
rptDocument.Load(Server.MapPath("WINGR0040.rpt"));
// Fetch report data.
...
rptDocument.SetDataSource(dsResult);
// Print report.
rptDocument.PrintToPrinter(1, false, 0, 0);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我确实会将报告导出为 PDF,以便用户在桌面打印机上进行打印。但是,iis 服务器上的打印后台处理程序服务可能已停止,因此 crytsal 会感到困惑。
I would really export the report to PDF so the user prints at their desktop printer. However maybe the Print Spooler Service is stopped on the iis server so crytsal is confused.
您是否已在网站运行所用的用户帐户下的 Web 服务器上添加了打印机?
您是否尝试过先设置打印机名称?
如果您的站点在 DOMAIN\WebService 等帐户下运行,您需要确保该用户帐户具有默认打印机。
您还可以尝试像这样设置打印机名称:
这将获得默认打印机。
这篇文章可能会帮助您实现此目的。
编辑:
MSDN 上的这篇文章描述了如何打印可以使用 Crystal Reports 和 ASP.NET 来实现。如果您没有实施这些解决方案中的任何一个,那么我认为您将无法打印客户端。
MSDN 链接中提到的 .cab 文件可以在这里找到:
Visual Studio 2005
或者
Visual Studio 2008
无需发布更多代码和有关如何生成的更多详细信息报告我不知道我能够完全回答你的问题。
谢谢
Have you added a printer on the Web server under the user account that site runs under?
Have you tried setting the printer name first?
If your site runs under an account e.g DOMAIN\WebService you need to ensure that this user account has a default printer.
You could also try setting the printer name like this:
This will get the default printer.
This article may help you get this working.
EDIT:
This article on MSDN describes how printing can be acheived using Crystal Reports and ASP.NET. If you are not implementing either of these solutions then I don't think you will be able to print client side.
The .cab file mentioned in the MSDN link can be found here:
Visual Studio 2005
or
Visual Studio 2008
Without you posting further code and more detail as to how you are generating the report I don't I am going to be able to fully answer your question.
Thanks
我没有找到客户端打印的方法。
服务器端对我来说是如何工作的:
在 Page_Load 上,我得到了这个:
现在在 button_click 上:
//这个对我有用
如果您的打印机没有在服务器端显示,请尝试这个:
来源:(https://support2.microsoft.com/default.aspx?scid=kb ;en-us;184291)
要使 IIS 能够使用 SYSTEM 帐户枚举网络打印机,请按照下列步骤操作。
注意 如果该进程在网络服务帐户下运行,则需要对新创建的注册表具有显式权限。
HKEY_CURRENT_USER\Printers\Connections
I dont found a way to print by client-side.
There go how works to me by server-side:
on Page_Load i got this:
Now on button_click:
//this one works for me
If your printer don`t show in your server-side, try this one:
Source: (https://support2.microsoft.com/default.aspx?scid=kb;en-us;184291)
To enable IIS to enumerate the network printers by using the SYSTEM account, follow these steps.
Note If the process is running under the Network Service account, explicit permissions to the newly created registry are required.
HKEY_CURRENT_USER\Printers\Connections