我已经在 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印刷水晶报表
婷婷同学_
相关分类