The System.Drawing.Printing namespace provides print-related services for Windows Forms applications.
Typically, when you print from a Windows Forms application, you create a new instance of the PrintDocument class, set properties, such as PrintDocument.DefaultPageSettings and PrintDocument.PrinterSettings, that describe how to print, and call the PrintDocument.Print method to actually print the document. Calling the PrintDocument.Print method raises the PrintDocument.PrintPage event, which should be handled to perform the document layout for printing.
Use the PrintPageEventArgs.Graphics property of the PrintPageEventArgs object obtained from the PrintDocument.PrintPage event to specify the output to print. If you are printing a text file, use StreamReader to read one line at a time from the stream and call the Graphics.DrawString(String,Font,Brush,PointF) method to draw the line in the graphics object. For more information about this process, see the Graphics and StreamReader classes. You can view an example of printing a text document in the PrintDocument class overview topic.
The erload:System.Windows.Forms.TextRenderer.DrawText methods of the TextRenderer class are not supported for printing. Instead, use the erload:System.Drawing.Graphics.DrawString methods of the Graphics class.
When implemented in a derived class, the PrintController controls how a PrintDocument is printed. The PrintDocument.Print method invokes the print controller's PrintController.OnStartPrint(PrintDocument,PrintEventArgs), PrintController.OnEndPrint(PrintDocument,PrintEventArgs), PrintController.OnStartPage(PrintDocument,PrintPageEventArgs), and PrintController.OnEndPage(PrintDocument,PrintPageEventArgs) methods, which in turn tell the printer how to print the document. For more information about printing dialog boxes, see PrintDialog and PageSetupDialog.
The print-preview process uses a specialized print controller, dialog box, and control. For an example of such a print controller and dialog box, see PreviewPrintController, PrintPreviewDialog, and PrintPreviewControl.
Classes within the System.Drawing.Printing namespace are not supported for use within a Windows service or ASP.NET application or service. Attempting to use these classes from within one of these application types may produce unexpected problems, such as diminished service performance and run-time exceptions.
If you want to print from a Windows Presentation Foundation (WPF) application, see the System.Printing namespace.
Specifies the printer's duplex setting.
Represents the exception that is thrown when you try to access a printer using printer settings that are not valid.
Specifies the dimensions of the margins of a printed page.
Specifies settings that apply to a single, printed page.
Specifies the standard paper sizes.
Specifies the size of a piece of paper.
Specifies the paper tray from which the printer gets paper.
Standard paper sources.
Specifies print preview information for a single page. This class cannot be inherited.
Specifies a print controller that displays a document on a screen as a series of images.
Specifies the type of print operation occurring.
Controls how a document is printed, when printing from a Windows Forms application.
Defines a reusable object that sends output to a printer, when printing from a Windows Forms application.
Represents the resolution supported by a printer.
Specifies a printer resolution.
Specifies information about how a document is printed, including the printer that prints it, when printing from a Windows Forms application.
Specifies several of the units of measure used for printing.
Specifies a series of conversion methods that are useful when interoperating with the Win32 printing API. This class cannot be inherited.
Controls access to printers. This class cannot be inherited.
Allows declarative printing permission checks.
Specifies the type of printing that code is allowed to do.
Provides data for the PrintDocument.PrintPage event.
Specifies the part of the document to print.
Provides data for the PrintDocument.QueryPageSettings event.
Specifies a print controller that sends information to a printer.