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?