我已经在 Windows 10 上设置了我的 iis 服务器,并且我已经在其上部署了一个 mvc-5 网络应用程序,除了 Crystal Reports PrintToPrinter 之外,一切都运行良好,当我尝试调用此方法时,没有任何打印,网络应用程序什么也不做,只是挂起那里。但是当我在同一台机器上用 vs17 开发这个应用程序时,printToPrinter 方法工作正常。它只会在 iis 上发布后卡住。我努力了popt.PrinterName = printerSettings.PrinterName; rd.ReportClientDocument.PrintOutputController.PrintReport(popt);这个方法也是。这是我的实际代码: DataTable dt = new DataTable(); string constr = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; using (SqlConnection con = new SqlConnection(constr)) { using (SqlCommand cmd = new SqlCommand(sqlQuery)) { using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.Connection = con; sda.SelectCommand = cmd; sda.Fill(dt); } } } ReportDocument rd = new ReportDocument(); rd.Load(Path.Combine(Server.MapPath("~/Reporting/Crystals/rptKitchenCopy.rpt"))); rd.SetDataSource(dt); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); stream.Seek(0, SeekOrigin.Begin); PrinterSettings settings = new PrinterSettings(); System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument(); CrystalDecisions.Shared.PrintLayoutSettings PrintLayout = new CrystalDecisions.Shared.PrintLayoutSettings(); System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings(); var dpn = settings.PrinterName; printerSettings.PrinterName = dpn; System.Drawing.Printing.PageSettings pSettings = new System.Drawing.Printing.PageSettings(printerSettings);我希望它也可以使用我在同一台机器上托管的默认打印机在 iis 服务器中打印。C#asp.net-mvciis印刷水晶报表
1 回答
婷婷同学_
TA贡献1844条经验 获得超8个赞
我找到了导致此问题的原因,因为我在 Windows 10 上托管和开发了我的 Web 应用程序(都在同一台机器上),问题背后的原因是默认情况下我的 Windows 10 iis 正在检测“microsoft print to pdf”作为默认值打印机,所以我已经从 Windows 功能中关闭了它并添加了
PrinterSettings 设置 = new PrinterSettings(); rd.PrintOptions.PrinterName = settings.PrinterName;
在我的代码中。希望有人有同样的问题。谢谢
- 1 回答
- 0 关注
- 61 浏览
添加回答
举报
0/150
提交
取消