System.Drawing.Printing 命名空間

System.Drawing.Printing 命名空間 (Namespace) 可為 Windows Form 應用程式提供列印相關的服務。 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 提供 MarginsProvides 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 Form 應用程式列印時,將要如何列印文件。Controls how a document is printed, when printing from a Windows Forms application.

PrintDocument

定義從 Windows Form 應用程式中列印時會將輸出傳送至印表機的可重複使用物件。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 Form 應用程式列印時,文件如何列印的相關資訊,包括用來列印的印表機。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

代表處理 QueryPageSettingsPrintDocument 事件的方法。Represents the method that handles the QueryPageSettings event of a PrintDocument.

備註

一般而言,當您列印 Windows Form 應用程式,您建立的新執行個體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.

另請參閱