August 2003
Intermediate to advanced
736 pages
14h 48m
English
All print controller implementations rely on the print document's print events to gather the drawing commands into the graphics object, either to spool to the printer or to show on the screen:
void printDocument1_PrintPage(object sender, PrintPageEventArgs e) {
// Draw to the e.Graphics object
Graphics g = e.Graphics;
using( Font font = new Font("Lucida Console", 72) ) {
g.DrawString("Hello,\nPrinter", font, ...);
}
}
Notice that this sample PrintPage event handler creates a font only for printing. For a single page, this code is fine, because it creates the font and then reclaims the font resources when the printing is complete. However, if we're printing more than one page, it's wasteful to create the font anew on each ...
Read now
Unlock full access