Przeglądaj źródła

3车间贴标机打印转180度

chenxy 4 lat temu
rodzic
commit
5f4abbbbab

+ 2 - 2
DK.Service/BarcodePrintService/BarcodePrintLogic.cs

@@ -960,7 +960,7 @@ namespace Dongke.IBOSS.PRD.Service.BarcodePrintService
                             //                   bytes[0].ToString(),
                             //                   Dongke.IBOSS.PRD.Basics.Library.LocalPath.LogExePath + @"printdebug\");
                             //生成电子票据;
-                            InvoiceLayoutPrinter.Print(printerName, 1, bytes, printData.Rows[0], printData);
+                            InvoiceLayoutPrinter.Print(printerName, 1, bytes, printData.Rows[0], printData, 1);
                             //Dongke.IBOSS.PRD.Basics.Library.OutputLog.TraceLog(Dongke.IBOSS.PRD.Basics.Library.LogPriority.Debug,
                             //                   "PrintBarcode_3BL",
                             //                   "barcode  --  " + barcode + System.Environment.NewLine +
@@ -1218,7 +1218,7 @@ namespace Dongke.IBOSS.PRD.Service.BarcodePrintService
                             int layoutID = Convert.ToInt32(layoutData2.Rows[0]["LayoutID"]);
                             byte[] bytes = layoutData2.Rows[0]["LayoutData"] as byte[];
                             //生成电子票据;
-                            InvoiceLayoutPrinter.Print(printerName, 1, bytes, printData.Rows[0], printData);
+                            InvoiceLayoutPrinter.Print(printerName, 1, bytes, printData.Rows[0], printData, 1);
                             // 打印记录
                             SetPrintLog(layoutID, printData, sUserInfo, 2, in_PrintWay, printerName);
                         }

+ 21 - 3
DK.Service/BarcodePrintService/InvoiceLayoutPrinter.cs

@@ -40,6 +40,11 @@ namespace Dongke.WinForm.Controls.InvoiceLayout
         private DataTable _printGridData = null;
 
         private PrintDocument _printDocument = new PrintDocument();
+
+        /// <summary>
+        /// 0:正常,1:旋转180,
+        /// </summary>
+        private int _printDirectionKind = 0;
         #endregion
 
         #region 构造函数
@@ -107,7 +112,7 @@ namespace Dongke.WinForm.Controls.InvoiceLayout
             }
         }
 
-        public static void Print(string printerName, short copies, byte[] layout, DataRow data, DataTable detail)
+        public static void Print(string printerName, short copies, byte[] layout, DataRow data, DataTable detail, int printDirectionKind = 0)
         {
             //Logger.Debug("打印开始0");
             if (layout == null || layout.Length == 0)
@@ -126,6 +131,9 @@ namespace Dongke.WinForm.Controls.InvoiceLayout
             {
                 //Logger.Debug("打印开始1");
                 InvoiceLayoutPrinter printer = new InvoiceLayoutPrinter();
+
+                printer._printDirectionKind = printDirectionKind;
+
                 printer.LayoutItems = new List<LayoutItem>();
                 printer.ReadLayout(layout);
                 printer._printData = data;
@@ -267,8 +275,18 @@ namespace Dongke.WinForm.Controls.InvoiceLayout
 
         private bool DrawPage(Graphics graphics)
         {
-			//try
-			{
+            if (_printDirectionKind == 1)
+            {
+                //System.Drawing.Drawing2D.Matrix mtxSave = e.Graphics.Transform;
+                //Matrix mtxRotate = layoutGraphics.Transform;
+                //mtxRotate.Rotate(180);
+                //e.Graphics.Transform.Rotate(180);
+                graphics.TranslateTransform(this.Property.PaperWidth, this.Property.PaperHeight);
+                graphics.RotateTransform(180);
+            }
+
+            //try
+            {
 				// 背景打印
 				if (this.Property.PrintBackground)
 				{