Example #1
0
        private void BigCardPrint(System.Drawing.Printing.PrintPageEventArgs e)
        {
            int oX = -3, oY = -13;  //偏移量
            int offLine = -15;
            int i       = 43;
            int j       = 2;

            int[] xPos = { 0, 50, 150, 200, 300 };
            int[] yPos = { 0, 182, 212, 242, 272, 302, 332, 362, 412, 420 };

            Font CFont  = new Font("黑体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            Font EFont  = new Font("Arial", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            Font EFont1 = new Font("Arial", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            Font sEFont = new Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            Font sCFont = new Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            //Font ssCFont = new Font("隶书", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));

            Font cCFont = new Font("宋体", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            Font eEFont = new Font("Arial", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

            StringFormat drawFormat1 = new StringFormat();

            drawFormat1.Alignment     = StringAlignment.Center;
            drawFormat1.LineAlignment = StringAlignment.Center;
            StringFormat formatLeft = new StringFormat();

            formatLeft.Alignment     = StringAlignment.Near;
            formatLeft.LineAlignment = StringAlignment.Near;
            //------------------------------------------------------------------------------------------1行
            Rectangle rec;


            rec        = new Rectangle(oX + xPos[1] - 10 - j, yPos[1] + oY + offLine + 5 - i, xPos[4] - xPos[1], yPos[2] - yPos[1]);
            rec.Height = 30;

            if (_lable.BandNo.Length == 1)
            {
                e.Graphics.DrawString(_lable.BatchNo.Trim() + "  0" + _lable.BandNo.Trim(), EFont, Brushes.Black, rec, drawFormat1);  //批次号
            }
            else
            {
                e.Graphics.DrawString(_lable.BatchNo.Trim() + "  " + _lable.BandNo.Trim(), EFont, Brushes.Black, rec, drawFormat1);  //批次号
            }
            if (_lable.Standard.Length > 0)
            {
                rec.X      = xPos[1] + oX - j;
                rec.Y      = yPos[2] + oY + offLine - i;
                rec.Width  = xPos[2] - xPos[1];
                rec.Height = 30;
                e.Graphics.DrawString(_lable.Standard.Trim(), sEFont, Brushes.Black, rec, drawFormat1); //标准
            }

            if (_lable.SteelType.Length > 0)
            {
                rec.X      = xPos[3] + oX - j - 35; //35
                rec.Y      = yPos[2] + oY + offLine - i;
                rec.Width  = xPos[4] - xPos[3] + 40;
                rec.Height = 34;
                e.Graphics.DrawString(_lable.SteelType.Trim(), EFont, Brushes.Black, rec, drawFormat1); //牌号
            }
            //------------------------------------------------------------------------------------------3行

            rec.X      = xPos[1] + oX - j;
            rec.Y      = yPos[3] + oY + offLine - i;
            rec.Width  = xPos[2] - xPos[1];
            rec.Height = 30;
            e.Graphics.DrawString("Φ" + _lable.Spec.Trim() + "mm", EFont, Brushes.Black, rec, drawFormat1);   //规格



            rec.X      = xPos[3] + oX - j; //35
            rec.Y      = yPos[3] + oY + offLine - i;
            rec.Width  = xPos[4] - xPos[3];
            rec.Height = 34;
            e.Graphics.DrawString(_lable.Length.Trim() + "m", EFont, Brushes.Black, rec, drawFormat1);   //长度

            //--------------------------------------------------------------------------------------------4行
            rec.X      = xPos[1] + oX - j;
            rec.Y      = yPos[4] + oY + offLine - i;
            rec.Width  = xPos[2] - xPos[1];
            rec.Height = 30;
            e.Graphics.DrawString(_lable.Weight.Trim() + "kg", EFont, Brushes.Black, rec, drawFormat1); //



            rec.X      = xPos[3] + oX - j; //35
            rec.Y      = yPos[4] + oY + offLine - i;
            rec.Width  = xPos[4] - xPos[3];
            rec.Height = 30;
            e.Graphics.DrawString(_lable.Count.Trim(), EFont, Brushes.Black, rec, drawFormat1); //重量



            //---------------------------------------------------------------------------------------------5行
            rec.X      = xPos[1] + oX + xPos[1] - 10;
            rec.Y      = yPos[5] + oY + offLine - 5 - i;
            rec.Width  = xPos[2] - xPos[1] + 80;
            rec.Height = 30;
            e.Graphics.DrawString(_lable.Date.ToString("yyyy") + "年" + _lable.Date.ToString("MM") + "月" + _lable.Date.ToString("dd") + "日" + _lable.Term.Trim(), CFont, Brushes.Black, rec, drawFormat1); //生产日期



            //---------------------------------------------------------------------------------------------7行
            if (_lable.PrintAddress)
            {
                rec.X      = xPos[0] + oX;
                rec.Y      = yPos[8] + oY - 43 - i;
                rec.Width  = xPos[4] - xPos[0];
                rec.Height = 20;
                e.Graphics.DrawString("云南 ● 玉溪", sCFont, Brushes.Black, rec, drawFormat1); //地点
            }

            Code128 c128 = new Code128();

            c128.printBigCode(_lable.BarCode, 280, 50, e);
        }
Example #2
0
        private void BigCardPrint(System.Drawing.Printing.PrintPageEventArgs e)
        {
            int oX = -3, oY = -13;  //偏移量
            int offLine = -15;
            int i = 43;
            int j = 2;

            int[] xPos = { 0, 50, 150, 200, 300 };
            int[] yPos = { 0, 182, 212, 242, 272, 302, 332, 362, 412, 420 };

            Font CFont = new Font("黑体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            Font EFont = new Font("Arial", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            Font EFont1 = new Font("Arial", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            Font sEFont = new Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            Font sCFont = new Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            //Font ssCFont = new Font("隶书", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));

            Font cCFont = new Font("宋体", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            Font eEFont = new Font("Arial", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

            StringFormat drawFormat1 = new StringFormat();
            drawFormat1.Alignment = StringAlignment.Center;
            drawFormat1.LineAlignment = StringAlignment.Center;
            StringFormat formatLeft = new StringFormat();
            formatLeft.Alignment = StringAlignment.Near;
            formatLeft.LineAlignment = StringAlignment.Near;
            //------------------------------------------------------------------------------------------1行
            Rectangle rec;

            rec = new Rectangle(oX + xPos[1] - 10 - j, yPos[1] + oY + offLine+5 - i, xPos[4] - xPos[1], yPos[2] - yPos[1]);
            rec.Height = 30;

            if (_lable.BandNo.Length == 1)
                e.Graphics.DrawString(_lable.BatchNo.Trim() + "  0" + _lable.BandNo.Trim(), EFont, Brushes.Black, rec, drawFormat1);  //批次号
            else
                e.Graphics.DrawString(_lable.BatchNo.Trim() + "  " + _lable.BandNo.Trim(), EFont, Brushes.Black, rec, drawFormat1);  //批次号

            if (_lable.Standard.Length > 0) {
            rec.X = xPos[1] + oX - j;
            rec.Y = yPos[2] + oY + offLine - i;
            rec.Width = xPos[2] - xPos[1];
            rec.Height = 30;
            e.Graphics.DrawString(_lable.Standard.Trim(), sEFont, Brushes.Black, rec, drawFormat1); //标准
            }

            if (_lable.SteelType.Length > 0) {
            rec.X = xPos[3] + oX - j - 35; //35
            rec.Y = yPos[2] + oY + offLine - i;
            rec.Width = xPos[4] - xPos[3] + 40;
            rec.Height = 34;
            e.Graphics.DrawString(_lable.SteelType.Trim(), EFont, Brushes.Black, rec, drawFormat1); //牌号
            }
            //------------------------------------------------------------------------------------------3行

                rec.X = xPos[1] + oX - j;
                rec.Y = yPos[3] + oY + offLine - i;
                rec.Width = xPos[2] - xPos[1];
                rec.Height = 30;
                e.Graphics.DrawString("Φ" + _lable.Spec.Trim()+"mm", EFont, Brushes.Black, rec, drawFormat1); //规格

                rec.X = xPos[3] + oX - j; //35
                rec.Y = yPos[3] + oY + offLine - i;
                rec.Width = xPos[4] - xPos[3];
                rec.Height = 34;
                e.Graphics.DrawString(_lable.Length.Trim()+"m", EFont, Brushes.Black, rec, drawFormat1); //长度

            //--------------------------------------------------------------------------------------------4行
            rec.X = xPos[1] + oX - j;
            rec.Y = yPos[4] + oY + offLine - i;
            rec.Width = xPos[2] - xPos[1];
            rec.Height = 30;
            e.Graphics.DrawString(_lable.Weight.Trim() + "kg", EFont, Brushes.Black, rec, drawFormat1); //

            rec.X = xPos[3] + oX  - j; //35
            rec.Y = yPos[4] + oY + offLine - i;
            rec.Width = xPos[4] - xPos[3];
            rec.Height = 30;
            e.Graphics.DrawString(_lable.Count.Trim(), EFont, Brushes.Black, rec, drawFormat1); //重量

            //---------------------------------------------------------------------------------------------5行
            rec.X = xPos[1] + oX + xPos[1] - 10 ;
            rec.Y = yPos[5] + oY + offLine -5 - i;
            rec.Width = xPos[2] - xPos[1] + 80;
            rec.Height = 30;
            e.Graphics.DrawString(_lable.Date.ToString("yyyy") + "年" + _lable.Date.ToString("MM") + "月" + _lable.Date.ToString("dd") + "日" + _lable.Term.Trim(), CFont, Brushes.Black, rec, drawFormat1); //生产日期

            //---------------------------------------------------------------------------------------------7行
            if (_lable.PrintAddress )
            {
                rec.X = xPos[0] + oX;
                rec.Y = yPos[8] + oY - 43 - i;
                rec.Width = xPos[4] - xPos[0];
                rec.Height = 20;
                e.Graphics.DrawString("云南 ● 玉溪", sCFont, Brushes.Black, rec, drawFormat1); //地点
            }

            Code128 c128 = new Code128();
            c128.printBigCode(_lable.BarCode, 280, 50, e);
        }