simple printing question

  • Thread starter Thread starter Jack Russell
  • Start date Start date
J

Jack Russell

Gee vb.net makes me feel dumb!

My understanding is that I set up and do all of my printing in the
printdocument printpage and handler using various graphics methods such
as drawstring.

Is that correct?

If so how do I force a form feed?

Thanks

Jack Russell
 
Jack,
A formfeed/page eject occurs when you return from the OnPrintPage event
of the document. So, you need to keep track of your print position outside
that (I normally use class variables for my PrintDocument subclass) and draw
each page image in OnPrintPage. Set HasMorePages on the PrintPageEventArgs
variable to true when another page needs to be done before returning and set
it to false when the print job is complete.
Yes, DrawString and the other drawing methods are for drawing on the
page. Normally using PrintDocument requires a slightly different logic path
for printing than previous MS methods for VB6, C++ although it is closer to
C++.
Note that to get precise width/height of strings for alignment or
centering you need to use one of the MeasureString overrides that includes a
StringFormat and supply an instance of StringFormat.GenericTypographic.
There are a lot of articles on this and other drawing/printing things in
microsoft.public.dotnet.framework.drawing.

Ron Allen
 
Ron,

Thanks

Jack

Ron said:
Jack,
A formfeed/page eject occurs when you return from the OnPrintPage event
of the document. So, you need to keep track of your print position outside
that (I normally use class variables for my PrintDocument subclass) and draw
each page image in OnPrintPage. Set HasMorePages on the PrintPageEventArgs
variable to true when another page needs to be done before returning and set
it to false when the print job is complete.
Yes, DrawString and the other drawing methods are for drawing on the
page. Normally using PrintDocument requires a slightly different logic path
for printing than previous MS methods for VB6, C++ although it is closer to
C++.
Note that to get precise width/height of strings for alignment or
centering you need to use one of the MeasureString overrides that includes a
StringFormat and supply an instance of StringFormat.GenericTypographic.
There are a lot of articles on this and other drawing/printing things in
microsoft.public.dotnet.framework.drawing.

Ron Allen
 
Back
Top