/// <summary> /// 构建配送详情面单 /// </summary> /// <param name="data"></param> private void BuildShippingDetailLabel(ShippingLabel data) { var xMargin = 15; var yMargin = 20; var y = 0; var pageWidth = 580; var fontSize1 = (int)FontSize.Size24; var fontSize2 = (int)FontSize.Size32; var pageHeight = 720 + data.CargoList.Count * (fontSize1 * 2 + yMargin * 2); // 设置打印页 Command.SetPage(pageWidth, pageHeight); //顶部logo var logo1 = new Bitmap("./Biz/Images/utopa.jpg"); int logo1Width = logo1.Width; var logo1Text = "此处应有广告语!"; int logo1TextWidth = logo1Text.Length * fontSize1 + xMargin; int logo1MarginLeft = (pageWidth - logo1Width - logo1TextWidth) / 2; Command.DrawImage(logo1MarginLeft, y, logo1); int logo1TextY = y + (logo1.Height - fontSize1) / 2; Command.DrawText(logo1MarginLeft + logo1Width + xMargin, logo1TextY, "此处应有广告语!", fontSize1, 0, true, false, false); y = y + yMargin + logo1.Height; //条形码 Command.DrawBarcode1D("128", xMargin + 5, y, data.Sheet, 3, 100, 3, 1); y = y + yMargin + 100; //全英文数字宽度减半 int sheetTextWidth = data.Sheet.Length * fontSize1 / 2; int sheetTextMarginLeft = (pageWidth - sheetTextWidth - xMargin) / 2; Command.DrawText(sheetTextMarginLeft, y, data.Sheet, fontSize1, 0, false, false, false); y += yMargin + fontSize1; //中部配送信息 int x1 = xMargin; int x2 = x1 + (fontSize2 * 4) + xMargin; DrawItem(Command, ref y, yMargin, x1, x2, "订单号", data.SourceSheet, fontSize1); DrawItem(Command, ref y, yMargin, x1, x2, "收货人", data.ConsigneeName, fontSize1, false); DrawItem(Command, ref y, yMargin, x1, x2, "联系电话", data.ConsigneePhone, fontSize1, false); //DrawItem(Command, ref y, yMargin, x1, x2, "收货地址", lomWaybill.ConsigneeStreet, fontSize1, false); Command.DrawText(x1, y, "收货地址", fontSize1, 0, false, false, false); Command.DrawTextArea(x2, y, pageWidth - x2 - xMargin, fontSize1 * 2, data.ConsigneeStreet, fontSize1, 0, 0); y += yMargin + fontSize2 * 2; Command.DrawDashLine(xMargin, y, pageWidth - xMargin * 2); y += yMargin; //商品列表 int cx1 = xMargin; int cargoNameWidth = 200; int cx2 = cx1 + cargoNameWidth; int cx3 = cx2 + 150; int cx4 = cx3 + 150; Command.DrawText(cx1, y, "商品名称", fontSize1, 0, false, false, false); Command.DrawText(cx2, y, "数量", fontSize1, 0, false, false, false); Command.DrawText(cx3, y, "单价", fontSize1, 0, false, false, false); Command.DrawText(cx4, y, "合计", fontSize1, 0, false, false, false); y += fontSize1 + yMargin; data.CargoList.ForEach(t => { var tmpY = y; Command.DrawText(cx1, tmpY, $"{t.CargoCode} {t.CargoName}", fontSize1, 0, false, false, false); tmpY += yMargin + fontSize1; Command.DrawText(cx2, tmpY, t.CargoQty.ToString("F"), fontSize1, 0, false, false, false); Command.DrawText(cx3, tmpY, t.CargoPrice.ToString("F"), fontSize1, 0, false, false, false); Command.DrawText(cx4, tmpY, $"{(t.CargoPrice * t.CargoQty):F}", fontSize1, 0, false, false, false); y = tmpY + fontSize1 + yMargin; }); Command.DrawDashLine(xMargin, y, pageWidth - xMargin * 2); y += yMargin; Command.DrawText(cx1, y, "合计", fontSize1, 0, false, false, false); Command.DrawText(cx2, y, $"{data.CargoList.Sum(x => x.CargoQty)}", fontSize1, 0, false, false, false); Command.DrawText(cx4, y, $"{data.CargoList.Sum(x => x.CargoPrice * x.CargoQty):F}", fontSize1, 0, false, false, false); y += fontSize1 + yMargin; Command.DrawDashLine(xMargin, y, pageWidth - xMargin * 2); y += yMargin; }
/// <summary> /// 构建配送面单 /// </summary> /// <param name="data"></param> /// <param name="currentPage"></param> /// <param name="totalPage"></param> private void BuildShippingLabel(ShippingLabel data, int currentPage, int totalPage) { var xMargin = 15; var yMargin = 20; var y = 0; var pageWidth = 580; var pageHeight = 860; var fontSize1 = (int)FontSize.Size24; var fontSize2 = (int)FontSize.Size32; // 设置打印页 Command.SetPage(pageWidth, pageHeight); // 打印长度超出限制500 无法使用多标签打印 //Command.SetQty(totalPage); //y += yMargin; //Command.DrawText(xMargin, y, "1", fontSize2, 0, true, false, false); //Command.Count(1); //Command.DrawText(xMargin + fontSize2, y, $"/2", fontSize2, 0, true, false, false); //顶部页码 Command.DrawText(xMargin, y, $"{currentPage}/{totalPage}", 48, 0, true, false, false); y = yMargin + fontSize2; //顶部logo var logo1 = new Bitmap("./Biz/Images/logo.jpg"); int logo1Width = logo1.Width; var logo1Text = "此处应有广告语!"; int logo1TextWidth = logo1Text.Length * fontSize1 + xMargin; int logo1MarginLeft = (pageWidth - logo1Width - logo1TextWidth) / 2; Command.DrawImage(logo1MarginLeft, y, logo1); int logo1TextY = y + (logo1.Height - fontSize1) / 2; Command.DrawText(logo1MarginLeft + logo1Width + xMargin, logo1TextY, "此处应有广告语!", fontSize1, 0, true, false, false); y = y + yMargin + logo1.Height; //条形码 Command.DrawBarcode1D("128", xMargin + 5, y, data.Sheet, 3, 100, 3, 1); y = y + yMargin + 100; //全英文数字宽度减半 int sheetTextWidth = data.Sheet.Length * fontSize1 / 2; int sheetTextMarginLeft = (pageWidth - sheetTextWidth - xMargin) / 2; Command.DrawText(sheetTextMarginLeft, y, data.Sheet, fontSize1, 0, true, false, false); y += yMargin + fontSize1; //中部配送信息 int x1 = xMargin; int x2 = x1 + (fontSize2 * 4) + xMargin; DrawItem(Command, ref y, yMargin, x1, x2, "订单号", data.SourceSheet, fontSize2); DrawItem(Command, ref y, yMargin, x1, x2, "配送中心", data.ShippingPointName, fontSize2, true); DrawItem(Command, ref y, yMargin, x1, x2, "配送片区", data.ShippingZoningName, fontSize2, false); DrawItem(Command, ref y, yMargin, x1, x2, "配送时段", $"{data.DeliveryTimeBegin:yyyy-MM-dd HH:mm} ~ {data.DeliveryTimeEnd:HH:mm}", fontSize2, true); //收件人信息 Command.DrawTextArea(x1, y, pageWidth - xMargin * 2, fontSize2 * 2, data.ConsigneeStreet, fontSize2, 0, 0); y += yMargin + fontSize2 * 2; Command.DrawText(x1, y, data.ConsigneePhone, fontSize2, 0, false, false, false); y += yMargin + fontSize2; Command.DrawText(x1, y, data.ConsigneeName, fontSize2, 0, false, false, false); y += yMargin + fontSize2; Command.DrawDashLine(xMargin, y, pageWidth - xMargin * 2); y += yMargin; //底部logo var logo2 = new Bitmap("./Biz/Images/logo.jpg"); int logo2Width = logo2.Width; int logo2MarginLeft = (pageWidth - logo2Width) / 2; Command.DrawImage(logo2MarginLeft, y, logo2); }