【发布时间】:2019-08-25 13:40:42
【问题描述】:
我正在 asp.net mvc 5 中创建一个 pos 应用程序,并使用水晶报表创建发票,现在当销售按钮单击时,我想打印该发票, 我的代码:
$.ajax({
type: 'POST',
contentType: 'application/json',
dataType: 'json',
url: '@Url.Action("SaveData", "PointOfSale")',
data: dataList,
success: function (data) {
if (data.isRedirect) {
window.setTimeout(function() {
window.location = data.redirectUrl;
},700);
toastr.success("Save Successfully.");
}
}
});
我的控制器:
public void GenerateInvoice(string invoice)
{
var invoiceData = _reportManager.InvoicePrint(invoice);
var strPath = Path.Combine(Server.MapPath("~/Reports/Invoice.rpt"));
DataSet objDataSet = invoiceData;
DataTable dataTable = objDataSet.Tables[0];
using (ReportDocument report = new ReportDocument())
{
report.Load(strPath);
report.Database.Tables["VEW_RPT_INVOICE_PRINT"].SetDataSource((DataTable)dataTable);
report.SetDatabaseLogon("saraecom", "saraecom");
report.PrintOptions.PrinterName = "EPSON TM-T82 Receipt";
report.PrintToPrinter(1, false, 0, 0);
}
}
但此代码仅在服务器打印机中打印发票,我如何在客户端计算机上打印?
我把PrintToPrinter改成report.ExportToHttpResponse(ExportFormatType.PortableDocFormat, System.Web.HttpContext.Current.Response, false, "crReport");
此代码下载报告为 pdf,如何在客户端打印机中打印而不是下载...
提前谢谢....
【问题讨论】:
标签: c# jquery asp.net-mvc crystal-reports