打印文件pdf c#

时间:2017-04-24 02:57:58

标签: c# asp.net-mvc-4 pdf printing

我正在创建一个pdf文件,这是我的代码:

 public ActionResult ImprimirPedido()
        {

            List<ReporteModel> lista = new List<ReporteModel>();

            ReporteModel obj = new ReporteModel();
            obj.Responsable = "juan peres";
            obj.TipoPago = "Efectivo";
            obj.Fecha = "02/05/2014";
            obj.NombreProducto = "chocolate";
            obj.Cantidad = "2";
            obj.Total = "54.00";

            lista.Add(obj);


            string directorio = "~/Models/";
            string urlarchivo = string.Format("{0}.{1}", "Reporte_Disenio", "rdlc");

            string fullpath = string.Format("{0}{1}", this.HttpContext.Server.MapPath(directorio), urlarchivo);

            ReportViewer repor = new ReportViewer();

            repor.Reset();
            repor.LocalReport.ReportPath = fullpath;
            ReportDataSource data = new ReportDataSource("DS_REPORT", lista);
            repor.LocalReport.DataSources.Add(data);
            repor.LocalReport.Refresh();

            byte[] file = repor.LocalReport.Render("PDF");

            return File(new MemoryStream(file).ToArray(),
                System.Net.Mime.MediaTypeNames.Application.Octet,
                string.Format("{0}{1}", "archivo.", "PDF"));

        }

现在我想在没有预览的情况下直接在打印机上打印,打印机安装在我的电脑上,带有iis。这里运行我的系统mvc4 .net。

0 个答案:

没有答案