Şaf*_*Gür 5 c# printing barcode
我使用此设备打印条形码,但打印机不会停止打印,在我关闭之前给我空标签.我发现了这个问题,但指定纸张尺寸对我没有帮助.
我使用的代码:
PrintDocument document = new PrintDocument();
document.DefaultPageSettings.PaperSize =
new PaperSize("Custom", Centimeters(7), Centimeters(5));
document.PrintPage += (s, a) =>
{
a.Graphics.DrawString("*123456*",
BarcodeFont,
new SolidBrush(Color.Black),
new Point(0, 0));
}
document.Print();
Run Code Online (Sandbox Code Playgroud)
厘米方法:
// Converts the unit "Hundredths of an inch" to centimeter.
int Centimeters(int centimeters)
{
return (int)((centimeters * 100) / 2.54);
}
Run Code Online (Sandbox Code Playgroud)
它正确地将条形码打印到第一个标签,但它不会停止.标签是7x5厘米.我根据这个设置纸张尺寸,我不知道我还能做什么.
编辑:将HasMorePages设置为false没有帮助,我知道这不是因为我使用的设备:我目前使用一些其他程序来打印条形码,它们都有效.
将HasMorePages属性设置eventArgs为false:
document.PrintPage += (s, a) =>
{
a.Graphics.DrawString("*123456*",
BarcodeFont,
new SolidBrush(Color.Black),
new Point(0, 0));
a.HasMorePages = false;
}
Run Code Online (Sandbox Code Playgroud)