0

Well, it's a very strange problem, and I already found a black magical solution. I'm curious about the reason.

I'm writing a program which use Brother QL-700 label printer to print labels. I need the labels be printed without showing the printer dialog. The label printer support different size of label rolls and the default size of label roll is 29mm, while what I need is 62mm. I found that I can set the Page Size by

PrintDocument doc = new PrintDocument();
PaperSize size = new PaperSize() ;
size.Width = 244;//2.44 inch = 62mm
size.Height = 244;
size.RawKind = 256;//RawKind=0 does not work, I don't know why
doc.PrinterSettings.DefaultPageSettings.PaperSize = size;

However, this won't work, the driver of Printer would show a message saying the width does not fit.

But if I change the copy the PrinterSettings from a PrintDialog(), without showing it,

PrintDialog dlg = new PrintDialog();

doc.PrinterSettings = dlg.PrinterSettings;

Then it works.

In conclusion, what I don't understand is why

size.RawKind = 256;

and

PrintDialog dlg = new PrintDialog();
doc.PrinterSettings = dlg.PrinterSettings;

can make the printer work?

Asad Saeeduddin
  • 46,193
  • 6
  • 90
  • 139
iuradz
  • 1,128
  • 1
  • 12
  • 25

1 Answers1

0

The documentation for RawKind does not state that 0 is a valid value. It also states that any value above 118 indicates a custom paper size. Since you are specifying a custom paper size, the value of 256 indicates that the size is custom and that is why it works.

John Koerner
  • 37,428
  • 8
  • 84
  • 134
  • Oh, I see. Do you know anything about the difference between the default PrinterSettings of PrintDialog and PrintDocument? – iuradz Mar 20 '15 at 18:17