using FastReport; using FastReport.Export.Pdf; using log4net; using NPOI.HSSF.Record.Chart; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Aucma.Core.PrintTo { public class PrintHelper { private static readonly log4net.ILog log = LogManager.GetLogger(typeof(PrintHelper)); public static bool Print(string printer,string orderNo,string materialName,string barCode) { try { //对接打印机 Report barReport = new Report(); barReport.Load(System.Environment.CurrentDirectory + @"\Report\MaterialBar.frx");//打印报表位置 // 设置打印机和打印选项 barReport.PrintSettings.ShowDialog = true; // 是否打开打印机选择框 barReport.PrintSettings.Printer = printer; // 设置打印机名称 barReport.PrintSettings.Copies = 1; // 设置打印份数 //barReport.PrintSettings.PageRange = "1-3"; // 设置打印页范围 barReport.SetParameterValue("BoxBarData.Order_No", orderNo);//订单码 barReport.SetParameterValue("BoxBarData.Order_Material_Name", materialName);//物料名称 barReport.SetParameterValue("BoxBarData.Bar_Code", barCode);//二维码 //barReport.Prepare(); //string BarPath = System.Environment.CurrentDirectory + @"\pdf\" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf"; //barReport.Export(new PDFExport(), BarPath); barReport.Print(); return true; } catch (Exception ex) { log.Error($"打印出错:{ex.Message}"); return false; } } } }