I am creating a pos application in asp.net mvc 5 and I create Invoice using crystal report, now when sale button will click I want to print that invoice, my code:
$.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.");
}
}
});
my controller:
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);
}
}
but this code just print invoice only in server printer, how can I print it in client computer?
I change PrintToPrinter
to report.ExportToHttpResponse(ExportFormatType.PortableDocFormat, System.Web.HttpContext.Current.Response, false, "crReport");
this code download report as pdf, how can i print it in client Printer instead of downloading...
thanks in advance....