c# printdialog 打印html,c# – ReportViewer.PrintDialog()在打印到Adobe PDF时抛出异常
我正在使用WinForms應(yīng)用程序,該應(yīng)用程序使用ReportViewer控件顯示一些Reporting Services報(bào)告.在這些屏幕上,我們?cè)试S用戶通過調(diào)用ReportViewer上的PrintDialog()方法來打印報(bào)表,如下所示:
_reportViewer.PrintDialog();
這在大多數(shù)情況下工作正常,它會(huì)打開標(biāo)準(zhǔn)的Windows打印對(duì)話框,用戶選擇要打印的打印機(jī),然后進(jìn)行打印.但是,當(dāng)用戶選擇使用“Adobe PDF”打印到PDF時(shí),它會(huì)拋出Win32Exception:指定的數(shù)據(jù)類型無效.用于選擇保存pdf的位置的文件對(duì)話框甚至都沒有出現(xiàn).
這僅適用于Adobe PDF打印機(jī).我安裝了NitroPDF并使用了他們的PDF打印機(jī),它沒有問題.
有沒有人知道可能導(dǎo)致這種情況發(fā)生的原因?
編輯:
這是堆棧跟蹤:
at System.Drawing.Printing.StandardPrintController.OnStartPrint(PrintDocument document, PrintEventArgs e)
at System.Windows.Forms.PrintControllerWithStatusDialog.OnStartPrint(PrintDocument document, PrintEventArgs e)
at System.Drawing.Printing.PrintController.Print(PrintDocument document)
at System.Drawing.Printing.PrintDocument.Print()
at Microsoft.Reporting.WinForms.ReportViewer.PrintDialog(PrinterSettings printerSettings)
at Microsoft.Reporting.WinForms.ReportViewer.PrintDialog()
解決方法:
這并沒有真正解決問題,而是在用戶眼中解決了這個(gè)問題.
捕獲PDF打印機(jī)拋出的錯(cuò)誤,然后調(diào)用Reporting Services中內(nèi)置的導(dǎo)出到PDF功能.即使打印到PDF打印機(jī),它也不會(huì)在Winforms中出錯(cuò).從用戶的角度來看,他們像平常一樣“打印到pdf”,體驗(yàn)是相同的.這是一個(gè)有效的工作.
標(biāo)簽:c,pdf,winforms,reporting-services
來源: https://codeday.me/bug/20190606/1189311.html
總結(jié)
以上是生活随笔為你收集整理的c# printdialog 打印html,c# – ReportViewer.PrintDialog()在打印到Adobe PDF时抛出异常的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: jquery php 抽奖,jquery
- 下一篇: 2008七款免费杀毒软件权威推荐