打标图像大小调节:
1. DrawImage(Image, Int32, Int32, Int32, Int32)
在指定位置并且按指定大小绘制指定的 Image。
public void DrawImage (System.Drawing.Image image, int x, int y, int width, int height);
参数
image Image
要绘制的 Image。
x Int32
所绘制图像的左上角的 x 坐标。
y Int32
所绘制图像的左上角的 y 坐标。
width Int32
所绘制图像的宽度。
height Int32
所绘制图像的高度。
2. Bitmap Generate2(string text, int width, int height)
/// <summary>
/// 生成一维条形码
/// </summary>
/// <param name="text">内容</param>
/// <param name="width">宽度</param>
/// <param name="height">高度</param>
/// <returns></returns>
public static Bitmap Generate2(string text, int width, int height)
{
if (string.IsNullOrEmpty(text))
{
return null;
}
BarcodeWriter writer = new BarcodeWriter();
//使用ITF 格式,不能被现在常用的支付宝、微信扫出来
//如果想生成可识别的可以使用 CODE_128 格式
//writer.Format = BarcodeFormat.ITF;
//writer.Format = BarcodeFormat.CODE_39;
writer.Format = BarcodeFormat.CODE_128;
EncodingOptions options = new EncodingOptions()
{
Width = width,
Height = height,
Margin = 2
};
writer.Options = options;
Bitmap map = writer.Write(text);
return map;
}
3. 标签尺寸(百分之一英寸,100 = 1英寸 = 25.4mm)
_printDocument.DefaultPageSettings.PaperSize = new PaperSize("CustomerSize", (Int32)200, _High);
//标签尺寸(百分之一英寸,100 = 1英寸 = 25.4mm)