Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

System.Drawing.Printing Namespace

 

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

ClassDescription
System_CAPS_pubclassInvalidPrinterException

Represents the exception that is thrown when you try to access a printer using printer settings that are not valid.

System_CAPS_pubclassMargins

Specifies the dimensions of the margins of a printed page.

System_CAPS_pubclassMarginsConverter

Provides a MarginsConverter for Margins.

System_CAPS_pubclassPageSettings

Specifies settings that apply to a single, printed page.

System_CAPS_pubclassPaperSize

Specifies the size of a piece of paper.

System_CAPS_pubclassPrinterSettings.PaperSizeCollection

Contains a collection of PaperSize objects.

System_CAPS_pubclassPaperSource

Specifies the paper tray from which the printer gets paper.

System_CAPS_pubclassPrinterSettings.PaperSourceCollection

Contains a collection of PaperSource objects.

System_CAPS_pubclassPreviewPageInfo

Specifies print preview information for a single page. This class cannot be inherited.

System_CAPS_pubclassPreviewPrintController

Specifies a print controller that displays a document on a screen as a series of images.

System_CAPS_pubclassPrintController

Controls how a document is printed, when printing from a Windows Forms application.

System_CAPS_pubclassPrintDocument

Defines a reusable object that sends output to a printer, when printing from a Windows Forms application.

System_CAPS_pubclassPrinterResolution

Represents the resolution supported by a printer.

System_CAPS_pubclassPrinterSettings.PrinterResolutionCollection

Contains a collection of PrinterResolution objects.

System_CAPS_pubclassPrinterSettings

Specifies information about how a document is printed, including the printer that prints it, when printing from a Windows Forms application.

System_CAPS_pubclassPrinterUnitConvert

Specifies a series of conversion methods that are useful when interoperating with the Win32 printing API. This class cannot be inherited.

System_CAPS_pubclassPrintEventArgs

Provides data for the BeginPrint and EndPrint events.

System_CAPS_pubclassPrintingPermission

Controls access to printers. This class cannot be inherited.

System_CAPS_pubclassPrintingPermissionAttribute

Allows declarative printing permission checks.

System_CAPS_pubclassPrintPageEventArgs

Provides data for the PrintPage event.

System_CAPS_pubclassQueryPageSettingsEventArgs

Provides data for the QueryPageSettings event.

System_CAPS_pubclassStandardPrintController

Specifies a print controller that sends information to a printer.

System_CAPS_pubclassPrinterSettings.StringCollection

This API supports the product infrastructure and is not intended to be used directly from your code. Contains a collection of String objects.

DelegateDescription
System_CAPS_pubdelegatePrintEventHandler

Represents the method that will handle the BeginPrint or EndPrint event of a PrintDocument.

System_CAPS_pubdelegatePrintPageEventHandler

Represents the method that will handle the PrintPage event of a PrintDocument.

System_CAPS_pubdelegateQueryPageSettingsEventHandler

Represents the method that handles the QueryPageSettings event of a PrintDocument.

EnumerationDescription
System_CAPS_pubenumDuplex

Specifies the printer's duplex setting.

System_CAPS_pubenumPaperKind

Specifies the standard paper sizes.

System_CAPS_pubenumPaperSourceKind

Standard paper sources.

System_CAPS_pubenumPrintAction

Specifies the type of print operation occurring.

System_CAPS_pubenumPrinterResolutionKind

Specifies a printer resolution.

System_CAPS_pubenumPrinterUnit

Specifies several of the units of measure used for printing.

System_CAPS_pubenumPrintingPermissionLevel

Specifies the type of printing that code is allowed to do.

System_CAPS_pubenumPrintRange

Specifies the part of the document to print.

Typically, when you print from a Windows Forms application, you create a new instance of the PrintDocument class, set properties, such as DefaultPageSettings and PrinterSettings, that describe how to print, and call the 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 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 DrawString 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.

System_CAPS_noteNote

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.

System_CAPS_cautionCaution

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.

Return to top
Show:
© 2016 Microsoft