c# printdialog 打印html,c# – ReportViewer.PrintDialog()在打印到Adobe PDF时抛出异常
我正在使用WinForms應(yīng)用程序,該應(yīng)用程序使用ReportViewer控件顯示一些Reporting Services報告.在這些屏幕上,我們允許用戶通過調(diào)用ReportViewer上的PrintDialog()方法來打印報表,如下所示:
_reportViewer.PrintDialog();
這在大多數(shù)情況下工作正常,它會打開標準的Windows打印對話框,用戶選擇要打印的打印機,然后進行打印.但是,當用戶選擇使用“Adobe PDF”打印到PDF時,它會拋出Win32Exception:指定的數(shù)據(jù)類型無效.用于選擇保存pdf的位置的文件對話框甚至都沒有出現(xiàn).
這僅適用于Adobe PDF打印機.我安裝了NitroPDF并使用了他們的PDF打印機,它沒有問題.
有沒有人知道可能導(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()
解決方法:
這并沒有真正解決問題,而是在用戶眼中解決了這個問題.
捕獲PDF打印機拋出的錯誤,然后調(diào)用Reporting Services中內(nèi)置的導(dǎo)出到PDF功能.即使打印到PDF打印機,它也不會在Winforms中出錯.從用戶的角度來看,他們像平常一樣“打印到pdf”,體驗是相同的.這是一個有效的工作.
標簽:c,pdf,winforms,reporting-services
來源: https://codeday.me/bug/20190606/1189311.html
總結(jié)
以上是生活随笔為你收集整理的c# printdialog 打印html,c# – ReportViewer.PrintDialog()在打印到Adobe PDF时抛出异常的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: jquery php 抽奖,jquery
- 下一篇: C#如何实现挂机锁