4
votes

I'm developing an application which must print labels. The label printer i'm using is a Brother QL-570. The label width is 66mm and the length of the labels needs to be approximately 45mm. The problem I'm having is that I am unable to configure the application to actually print the labels. Everytime I do so I receive a warning stating that the document size is too large for the printer. No matter what size I attempt to change the PrintDocument size to I always receieve a warning stating that the document is 90mm x 29mm and is too large for the label printer.

Here's just one of my attempts:

private PrintDocument label;


label = new PrintDocument();
PaperSize pS = new PaperSize("Custom Size", 212, 67);
label.DefaultPageSettings.PaperSize = pS;
label.PrinterSettings.PrinterName = "Brother QL-570";
label.PrinterSettings.DefaultPageSettings.PaperSize = pS;
label.PrintPage += new PrintPageEventHandler(label_PrintPage);

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, 30, 30);

}

Has anyone any idea where I'm going wrong? I think I may be setting up the paper size for both the document and the printer incorrectly. I've tried numerous other paper sizes and to no avail.

Thanks For Any Help.

2
Printers can be cranky about custom paper sizes. Have you tried not setting the paper size so you'll just use the default that was selected by the driver? Configure the driver as necessary to select that size.Hans Passant
Thanks For Your Reply Hans. I've tried that also but it's still refusing to print as the document is too large.slickboy
Providing code that compiles would be helpful. new PaperSize("Custom Size, 212, 67); ?Peter Ritchie
So, what's the paper size you selected on the printer driver with its Printer preferences?Hans Passant
Sorry Peter. That was a typo. It still doesnt work when it compiles.slickboy

2 Answers

5
votes

The problem was not a programming problem but a printer configuration problem. By default the printer was configured to use a different paper size other than the one I was using. Thanks for all your help.

2
votes

Thanks. Your comment helped me with a similar issue. It appears that these Brother label printers plainly ignore the PageSettings properties.. once you have it working try putting some wild values in there. Completely ignored - crazy! Set a large enough print area and ensure that you are drawing within the right rectangle and you'll be fine.