/// <summary>
/// 生成条码字节流
/// </summary>
/// <param name="code"></param>
/// <param name="height"></param>
/// <param name="barcodeFormat"></param>
/// <returns></returns>
public static byte[] BarCode(string code, int width = 120, int height = 55, BarcodeFormat barcodeFormat = BarcodeFormat.CODE_128)
{
try
{
BarcodeWriter barcodeWriter = new BarcodeWriter()
{
Format = barcodeFormat,
Options = new EncodingOptions(){
Width = width,
Height = height,
Margin = 1
}
};
Bitmap img = barcodeWriter.Write(code);
MemoryStream ms = new MemoryStream();
img.Save(ms, ImageFormat.Jpeg);
return ms.ToArray();
}
catch (Exception ex)
{
throw ex;
}
/// 生成条码字节流
/// </summary>
/// <param name="code"></param>
/// <param name="height"></param>
/// <param name="barcodeFormat"></param>
/// <returns></returns>
public static byte[] BarCode(string code, int width = 120, int height = 55, BarcodeFormat barcodeFormat = BarcodeFormat.CODE_128)
{
try
{
BarcodeWriter barcodeWriter = new BarcodeWriter()
{
Format = barcodeFormat,
Options = new EncodingOptions(){
Width = width,
Height = height,
Margin = 1
}
};
Bitmap img = barcodeWriter.Write(code);
MemoryStream ms = new MemoryStream();
img.Save(ms, ImageFormat.Jpeg);
return ms.ToArray();
}
catch (Exception ex)
{
throw ex;
}