/// <summary> /// 读取打印设置 /// </summary> /// <returns></returns> public RawPrintSetting GetRawPrintSettings() { if (string.IsNullOrEmpty(templateName)) { return(null); } var rps = new RawPrintSetting() { LandScape = false }; try { if (File.Exists(FilePath)) { using (var stream = new StreamReader(FilePath, Encoding.UTF8)) { var json = stream.ReadToEnd(); rps = JsonConvert.DeserializeObject <RawPrintSetting>(json); } } else { rps = DefaultSetting(); } } catch (Exception exp) { XMessageBox.Warning(string.Format("加载打印设置出错,您需要重新设置并保存")); } return(rps); }
/// <summary> /// 创建二维码 /// </summary> /// <param name="recordno"></param> /// <param name="fileName"></param> public static bool CreateQRCode(string recordno, string fileName, string path) { try { Zen.Barcode.CodeQrBarcodeDraw zen = Zen.Barcode.BarcodeDrawFactory.CodeQr; var image = zen.Draw(recordno, 25); var file = Path.Combine(path, fileName + ".bmp"); image.Save(file); image.Dispose(); return(true); } catch (Exception ex) { XMessageBox.Error(ex.Message); return(false); } }
/// <summary> /// 创建条形码 /// </summary> /// <param name="recordno"></param> /// <param name="fileName"></param> /// <returns></returns> public static bool CreateBarCode(string recordno, string fileName, string path) { try { Zen.Barcode.Code128BarcodeDraw zen = Zen.Barcode.BarcodeDrawFactory.Code128WithChecksum; var scale = int.Parse(System.Configuration.ConfigurationManager.AppSettings["BarCodeScale"] ?? "2"); var height = int.Parse(System.Configuration.ConfigurationManager.AppSettings["BarCodeHeight"] ?? "60"); var image = zen.Draw(recordno, height, scale); var file = Path.Combine(path, fileName + ".bmp"); image.Save(file); image.Dispose(); return(true); } catch (Exception ex) { XMessageBox.Error(ex.Message); return(false); } }