4,816
社区成员




BarcodeControl barcode = new BarcodeControl();
barcode.BarcodeType = BarcodeType.EAN13;
barcode.Data = "123456";
barcode.CopyRight = "";
barcode.HorizontalAlignment = BarcodeHorizontalAlignment.Center;//对齐方式
barcode.StretchText = true;
RectangleF f = GetRectangle(PageCount);
f.Y += 46;
f.Height = 10;
f.Width = 25;
MemoryStream stream = new MemoryStream();
//中间传参数宽为1 高为50图像就正常但分辨率太低 如果宽和高调大 图像就不成比例了
//结果就看不到条形码下面的数字了
barcode.MakeImage(System.Drawing.Imaging.ImageFormat.Jpeg, 2, 130, true, false, null, stream);
System.Drawing.Image barcodeImage = System.Drawing.Image.FromStream(stream);
g.DrawImage(barcodeImage, f);
stream.Dispose();//释放资源
BarcodeControl barcode = new BarcodeControl();
barcode.BarcodeType = BarcodeType.EAN13;
barcode.Data = "012345678912";
barcode.CopyRight = "";
barcode.HorizontalAlignment = BarcodeHorizontalAlignment.Center;//对齐方式
barcode.StretchText = true;
barcode.Font = new Font("Arial", 180f, FontStyle.Regular);
MemoryStream stream = new MemoryStream();
barcode.MakeImage(System.Drawing.Imaging.ImageFormat.Jpeg, 25, 1500, true, false, null, stream);
System.Drawing.Image barcodeImage = System.Drawing.Image.FromStream(stream);
g.PageUnit = GraphicsUnit.Millimeter;
g.DrawImage(barcodeImage, f);
stream.Dispose();//释放资源