Exemplo n.º 1
0
        /// <summary>
        /// Generate barcode
        /// </summary>
        /// <returns></returns>
        public System.Drawing.Image Barcode(string order_numer = "", double scale = 1.1d)
        {
            if (string.IsNullOrEmpty(order_numer))
            {
                order_numer = Order.Order_Number;
            }
            int barcode_width = (int)(Code128Rendering.EstimateWidth(order_numer, 2, false) * scale);

            System.Drawing.Image image = new System.Drawing.Bitmap(barcode_width, 70);

            Graphics g = Graphics.FromImage(image);

            g.Clear(Color.White);
            System.Drawing.Font font         = new System.Drawing.Font("Tahoma", 14, FontStyle.Bold);
            StringFormat        center_align = new StringFormat();

            center_align.Alignment = StringAlignment.Center;

            var y = Code128Rendering.MakeBarcodeImage(order_numer, 2, false, ref g, 1, barcode_width);

            y += 3;
            g.DrawString(Order.Order_Number, font, Brushes.Black, barcode_width / 2, y, center_align);

            font.Dispose();
            g.Dispose();
            return(image);
        }