I am successfully printing labels directly to a Brother QL label printer using the code below. The problem is that the printer seems to be ignoring the custom length I am trying to set at run time via c# to result in a longer or shorter label. I can change the page length in Windows Printer Settings but I am unable to set a custom label length at run time which would be dependent on the amount of information I'm rendering on a particular label. Note that I know I can use bPac to print a variable length label but I would really like to get away from using their templates. I've found them to be unnecessarily cumbersome. Well, unnecessary unless I'm unable to set a custom length otherwise.
Any suggestions would be appreciated.
Thank you for reading.
Here's the code I'm using:
private void SingleLabel()
{
label = new PrintDocument();
PaperSize pS = new PaperSize("Custom Size", 242, 55);
label.DefaultPageSettings.PaperSize = pS;
label.PrinterSettings.PrinterName = "Label_1";
label.PrinterSettings.DefaultPageSettings.PaperSize = pS;
label.PrintPage += new PrintPageEventHandler(label_PrintPage);
label.Print();
}
private void label_PrintPage(object sender, PrintPageEventArgs e)
{
SolidBrush brush = new SolidBrush(Color.Black);
Font header = new Font(FontFamily.GenericSansSerif, 12.0F, FontStyle.Bold);
e.Graphics.DrawString("Hello World", header, brush, 0, 0);
}