private void button1_Click(object sender, EventArgs e) { String data = txtStr.Text.Trim().ToUpper(); int ww = picBarCodeImg.Width / 4; int hh = picBarCodeImg.Height / 4; string otherText = "some text will show here draw datastring under the barcode image some text will show here draw datastring under the barcode image"; //BarcodeForImg nb = new BarcodeForImg(data, otherText, NetBarcode.Type.Code128A, true, ww, hh, new Font("Consolas", 12)); //picBarCodeImg.Image = nb.GetImage(); try { FbaLable itlab = new FbaLable(data, "some text will show here draw datastring under the barcode image some text will show here draw datastring under the barcode image", NetBarcode.Type.Code128A); picBarCodeImg.Image = itlab.GetItemLable(); }catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// 打印的内容,这相当于打印机内,在里面画出的内容全部会打印出来 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void printDocument_PrintPage(object sender, PrintPageEventArgs e) { String data = txtStr.Text.Trim().ToUpper(); try { FbaLable itlab = new FbaLable(data, "测试标签打印some text will show here draw datastring under the barcode image some text will show here draw datastring under the barcode image", NetBarcode.Type.Code128A); Image image = itlab.GetItemLable(); e.Graphics.DrawImage(image, 0, 0); //画更多的图 //Font printFont = new Font("宋体", 12, System.Drawing.FontStyle.Regular); //var printColor = System.Drawing.Brushes.Black; ////画字符串 //e.Graphics.DrawString(data, printFont, Brushes.Black,0, image.Height+50); e.HasMorePages = false; } catch (Exception ex) { MessageBox.Show(ex.Message); } }