private void DrawBarcode(string barcode)
        {
            if (string.IsNullOrEmpty(barcode))
            {
                return;
            }
            var code39 = new Code39
                             {
                                 FontFamilyName = "Free 3 of 9",
                                 FontFileName = "Common\\FREE3OF9.TTF",
                                 ShowCodeString = true,
                                 FontSize = 60
                             };

            Image codeGen = code39.GenerateBarcode(barcode);

            //Ean13 ean13 = new Ean13(barcode.Substring(0, 2), barcode.Substring(2, 7), barcode.Substring(7, 6));
            //Ean13 ean13 = new Ean13("12", "34567", "89012");

            if (codeGen != null)
            {
                picBarcode.Image = codeGen;
                //picBarcode.Image = ean13.CreateBitmap();
            }
        }
        private void barcodePrintDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            var height = 87;
            var numberToPrint = (int)numericUpDown.Value;

            if (numberToPrint > 3)
            {
                height = (numberToPrint / 3) * 87;
            }
            var fullImg = new Bitmap(416, height);
            var code39 = new Code39
            {
                FontFamilyName = "Free 3 of 9",
                FontFileName = "Common\\FREE3OF9.TTF",
                ShowCodeString = true,
                FontSize = 25,
                Title = "Giá " + DepartmentPrice.Price.ToString("##,#00") + " VND"
            };

            var codeGen = code39.GenerateBarcode(txtBarcode.Text);
            for (int i = 0; i < numericUpDown.Value; i++)
            {
                e.Graphics.DrawImage(codeGen, (i % 3) * 124, (i / 3) * 87, 117, 79);
            }
        }