System.Drawing.Printing Namespace

The System.Drawing.Printing namespace provides print-related services for Windows Forms applications.

Typically, when printing from a Windows Forms application, you create a new instance of the PrintDocument class, set the properties that describe what to print, and call the Print method to actually print the document.


The classes that are contained in this namespace should be used when printing from a Windows Forms application. If you are printing from a Windows Presentation Foundation application, see the System.Printing namespace or Printing Overview

Use the Graphics property to specify the output to print. If you are printing a text file, use StreamReader in the following manner: read one line at a time from the stream and call the DrawString method to draw the line in the graphics object. For more information about this process, see the Graphics and StreamReader classes.


The DrawText methods of the TextRenderer class are not supported for printing. Instead, use the 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 OnStartPrint, OnEndPrint, OnStartPage, and OnEndPage 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.

Caution noteCaution:

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.

Public classInvalidPrinterExceptionRepresents the exception that is thrown when you try to access a printer using printer settings that are not valid.
Public classMarginsSpecifies the dimensions of the margins of a printed page.
Public classMarginsConverterProvides a MarginsConverter for Margins.
Public classPageSettingsSpecifies settings that apply to a single, printed page.
Public classPaperSizeSpecifies the size of a piece of paper.
Public classPaperSourceSpecifies the paper tray from which the printer gets paper.
Public classPreviewPageInfoSpecifies print preview information for a single page. This class cannot be inherited.
Public classPreviewPrintControllerSpecifies a print controller that displays a document on a screen as a series of images.
Public classPrintControllerControls how a document is printed, when printing from a Windows Forms application.
Public classPrintDocumentDefines a reusable object that sends output to a printer, when printing from a Windows Forms application.
Public classPrinterResolutionRepresents the resolution supported by a printer.
Public classPrinterSettingsSpecifies information about how a document is printed, including the printer that prints it, when printing from a Windows Forms application.
Public classPrinterSettings.PaperSizeCollectionContains a collection of PaperSize objects.
Public classPrinterSettings.PaperSourceCollectionContains a collection of PaperSource objects.
Public classPrinterSettings.PrinterResolutionCollectionContains a collection of PrinterResolution objects.
Public classPrinterSettings.StringCollectionContains a collection of String objects.
Public classPrinterUnitConvertSpecifies a series of conversion methods that are useful when interoperating with the Win32 printing API. This class cannot be inherited.
Public classPrintEventArgsProvides data for the BeginPrint and EndPrint events.
Public classPrintingPermissionControls access to printers. This class cannot be inherited.
Public classPrintingPermissionAttributeAllows declarative printing permission checks.
Public classPrintPageEventArgsProvides data for the PrintPage event.
Public classQueryPageSettingsEventArgsProvides data for the QueryPageSettings event.
Public classStandardPrintControllerSpecifies a print controller that sends information to a printer.

Public delegatePrintEventHandlerRepresents the method that will handle the BeginPrint or EndPrint event of a PrintDocument.
Public delegatePrintPageEventHandlerRepresents the method that will handle the PrintPage event of a PrintDocument.
Public delegateQueryPageSettingsEventHandlerRepresents the method that handles the QueryPageSettings event of a PrintDocument.

Public enumerationDuplexSpecifies the printer's duplex setting.
Public enumerationPaperKindSpecifies the standard paper sizes.
Public enumerationPaperSourceKindStandard paper sources.
Public enumerationPrintActionSpecifies the type of print operation occurring.
Public enumerationPrinterResolutionKindSpecifies a printer resolution.
Public enumerationPrinterUnitSpecifies several of the units of measure used for printing.
Public enumerationPrintingPermissionLevelSpecifies the type of printing that code is allowed to do.
Public enumerationPrintRangeSpecifies the part of the document to print.