我已經(jīng)在 Windows 10 上設(shè)置了我的 iis 服務(wù)器,并且我已經(jīng)在其上部署了一個(gè) mvc-5 網(wǎng)絡(luò)應(yīng)用程序,除了 Crystal Reports PrintToPrinter 之外,一切都運(yùn)行良好,當(dāng)我嘗試調(diào)用此方法時(shí),沒有任何打印,網(wǎng)絡(luò)應(yīng)用程序什么也不做,只是掛起那里。但是當(dāng)我在同一臺(tái)機(jī)器上用 vs17 開發(fā)這個(gè)應(yīng)用程序時(shí),printToPrinter 方法工作正常。它只會(huì)在 iis 上發(fā)布后卡住。我努力了popt.PrinterName = printerSettings.PrinterName; rd.ReportClientDocument.PrintOutputController.PrintReport(popt);這個(gè)方法也是。這是我的實(shí)際代碼: 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);我希望它也可以使用我在同一臺(tái)機(jī)器上托管的默認(rèn)打印機(jī)在 iis 服務(wù)器中打印。C#asp.net-mvciis印刷水晶報(bào)表
1 回答

婷婷同學(xué)_
TA貢獻(xiàn)1844條經(jīng)驗(yàn) 獲得超8個(gè)贊
我找到了導(dǎo)致此問(wèn)題的原因,因?yàn)槲以?Windows 10 上托管和開發(fā)了我的 Web 應(yīng)用程序(都在同一臺(tái)機(jī)器上),問(wèn)題背后的原因是默認(rèn)情況下我的 Windows 10 iis 正在檢測(cè)“microsoft print to pdf”作為默認(rèn)值打印機(jī),所以我已經(jīng)從 Windows 功能中關(guān)閉了它并添加了
PrinterSettings 設(shè)置 = new PrinterSettings(); rd.PrintOptions.PrinterName = settings.PrinterName;
在我的代碼中。希望有人有同樣的問(wèn)題。謝謝
- 1 回答
- 0 關(guān)注
- 106 瀏覽
添加回答
舉報(bào)
0/150
提交
取消