System.Drawing.Printing Namespace

System.Drawing.Printing 命名空间为 Windows 窗体应用程序提供与打印相关的服务。 The System.Drawing.Printing namespace provides print-related services for Windows Forms applications.

InvalidPrinterException

表示当尝试用无效的打印机设置来访问打印机时所引发的异常。 Represents the exception that is thrown when you try to access a printer using printer settings that are not valid.

Margins

指定打印页的边距尺寸。 Specifies the dimensions of the margins of a printed page.

MarginsConverter

MarginsConverter 提供一个 Margins Provides a MarginsConverter for Margins.

PageSettings

指定应用于单页打印的设置。 Specifies settings that apply to a single, printed page.

PaperSize

指定纸张大小。 Specifies the size of a piece of paper.

PaperSource

指定给打印机送纸的纸盒。 Specifies the paper tray from which the printer gets paper.

PreviewPageInfo

为单页指定打印预览信息。 Specifies print preview information for a single page. 此类不能被继承。 This class cannot be inherited.

PreviewPrintController

指定一个打印控制器,它在屏幕上将文档显示为一系列图像。 Specifies a print controller that displays a document on a screen as a series of images.

PrintController

控制在从 Windows 窗体应用程序打印时如何打印文档。 Controls how a document is printed, when printing from a Windows Forms application.

PrintDocument

从 Windows 窗体应用程序打印时,定义一种可重用的可发送到打印机上的对象。 Defines a reusable object that sends output to a printer, when printing from a Windows Forms application.

PrinterResolution

表示打印机支持的分辨率。 Represents the resolution supported by a printer.

PrinterSettings

指定有关在从 Windows 窗体应用程序打印时如何打印文档的信息,包括打印文档的打印机。 Specifies information about how a document is printed, including the printer that prints it, when printing from a Windows Forms application.

PrinterSettings.PaperSizeCollection

包含 PaperSize 对象的集合。 Contains a collection of PaperSize objects.

PrinterSettings.PaperSourceCollection

包含 PaperSource 对象的集合。 Contains a collection of PaperSource objects.

PrinterSettings.PrinterResolutionCollection

包含 PrinterResolution 对象的集合。 Contains a collection of PrinterResolution objects.

PrinterSettings.StringCollection

包含 String 对象的集合。 Contains a collection of String objects.

PrinterUnitConvert

指定一系列与 Win32 打印 API 互操作时非常有用的转换方法。 Specifies a series of conversion methods that are useful when interoperating with the Win32 printing API. 此类不能被继承。 This class cannot be inherited.

PrintEventArgs

提供有关 BeginPrintEndPrint 事件的数据。 Provides data for the BeginPrint and EndPrint events.

PrintingPermission

控制对打印机的访问。 Controls access to printers. 此类不能被继承。 This class cannot be inherited.

PrintingPermissionAttribute

允许进行声明打印权限检查。 Allows declarative printing permission checks.

PrintPageEventArgs

PrintPage 事件提供数据。 Provides data for the PrintPage event.

QueryPageSettingsEventArgs

QueryPageSettings 事件提供数据。 Provides data for the QueryPageSettings event.

StandardPrintController

指定一个打印控制器,它向打印机发送信息。 Specifies a print controller that sends information to a printer.

枚举

Duplex

指定打印机的双面打印设置。 Specifies the printer's duplex setting.

PaperKind

指定标准纸张大小。 Specifies the standard paper sizes.

PaperSourceKind

标准的纸张来源。 Standard paper sources.

PrintAction

指定正在进行的打印操作的类型。 Specifies the type of print operation occurring.

PrinterResolutionKind

指定打印机的分辨率。 Specifies a printer resolution.

PrinterUnit

指定几个用于打印的度量单位。 Specifies several of the units of measure used for printing.

PrintingPermissionLevel

指定允许代码进行的打印类型。 Specifies the type of printing that code is allowed to do.

PrintRange

指定要打印的文档部分。 Specifies the part of the document to print.

委托

PrintEventHandler

表示将对 BeginPrintEndPrintPrintDocument 事件进行处理的方法。 Represents the method that will handle the BeginPrint or EndPrint event of a PrintDocument.

PrintPageEventHandler

表示将要处理 PrintPagePrintDocument 事件的方法。 Represents the method that will handle the PrintPage event of a PrintDocument.

QueryPageSettingsEventHandler

表示处理 PrintDocumentQueryPageSettings 事件的方法。 Represents the method that handles the QueryPageSettings event of a PrintDocument.

注解

通常情况下,当从 Windows 窗体应用程序打印时,你创建的新实例PrintDocument类中,设置属性,如DefaultPageSettingsPrinterSettings,用于描述如何打印和调用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. 调用PrintDocument.Print方法将引发PrintDocument.PrintPage事件,应处理来执行打印文档的布局。Calling the PrintDocument.Print method raises the PrintDocument.PrintPage event, which should be handled to perform the document layout for printing.

使用Graphics的属性PrintPageEventArgs对象,来自PrintDocument.PrintPage事件,以指定要打印的输出。Use the Graphics property of the PrintPageEventArgs object obtained from the PrintDocument.PrintPage event to specify the output to print. 如果要打印的文本文件,使用StreamReader以便从流,并调用一次读取一行DrawString方法来绘制图形对象中的行。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. 有关此过程的详细信息,请参阅GraphicsStreamReader类。For more information about this process, see the Graphics and StreamReader classes. 您可以查看打印文本文档中的示例PrintDocument类概述主题。You can view an example of printing a text document in the PrintDocument class overview topic.

备注

DrawText方法的TextRenderer类不支持打印。The DrawText methods of the TextRenderer class are not supported for printing. 请改用DrawString方法的Graphics类。Instead, use the DrawString methods of the Graphics class.

在派生类中实现时PrintController控件如何PrintDocument打印。When implemented in a derived class, the PrintController controls how a PrintDocument is printed. PrintDocument.Print方法将调用打印控制器OnStartPrintOnEndPrintOnStartPage,和OnEndPage方法指示打印机如何打印文档的方法。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. 有关打印对话框的详细信息,请参阅PrintDialogPageSetupDialogFor more information about printing dialog boxes, see PrintDialog and PageSetupDialog.

打印预览过程使用专用的打印控制器,对话框中和控制。The print-preview process uses a specialized print controller, dialog box, and control. 此类的打印控制器和对话框中的示例,请参阅PreviewPrintControllerPrintPreviewDialog,和PrintPreviewControlFor an example of such a print controller and dialog box, see PreviewPrintController, PrintPreviewDialog, and PrintPreviewControl.

小心

类中System.Drawing.Printing命名空间不支持的 Windows 服务或 ASP.NET 应用程序或服务中的使用。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.

如果你想要从 Windows Presentation Foundation (WPF) 应用程序打印,请参阅System.Printing命名空间。If you want to print from a Windows Presentation Foundation (WPF) application, see the System.Printing namespace.