System.Drawing.Printing Przestrzeń nazw
Program udostępnia usługi dotyczące drukowania Windows Forms aplikacji. Provides print-related services for Windows Forms applications.
Klasy
InvalidPrinterException |
Reprezentuje wyjątek, który jest generowany podczas próby uzyskania dostępu do drukarki przy użyciu ustawień drukarki, które są nieprawidłowe.Represents the exception that is thrown when you try to access a printer using printer settings that are not valid. |
Margins |
Określa wymiary marginesów drukowanej strony.Specifies the dimensions of the margins of a printed page. |
MarginsConverter |
Zapewnia MarginsConverter Margins .Provides a MarginsConverter for Margins. |
PageSettings |
Określa ustawienia, które mają zastosowanie do pojedynczej, drukowanej strony.Specifies settings that apply to a single, printed page. |
PaperSize |
Określa rozmiar fragmentu papieru.Specifies the size of a piece of paper. |
PaperSource |
Określa zasobnik papieru, z którego drukarka pobiera papier.Specifies the paper tray from which the printer gets paper. |
PreviewPageInfo |
Określa informacje o Podglądzie wydruku dla pojedynczej strony.Specifies print preview information for a single page. Klasa ta nie może być dziedziczona.This class cannot be inherited. |
PreviewPrintController |
Określa Kontroler wydruku, który wyświetla dokument na ekranie jako serię obrazów.Specifies a print controller that displays a document on a screen as a series of images. |
PrintController |
Kontroluje sposób drukowania dokumentu podczas drukowania z aplikacji Windows Forms.Controls how a document is printed, when printing from a Windows Forms application. |
PrintDocument |
Definiuje obiekt wielokrotnego użytku, który wysyła dane wyjściowe do drukarki podczas drukowania z aplikacji Windows Forms.Defines a reusable object that sends output to a printer, when printing from a Windows Forms application. |
PrinterResolution |
Reprezentuje rozdzielczość obsługiwaną przez drukarkę.Represents the resolution supported by a printer. |
PrinterSettings |
Określa informacje o sposobie drukowania dokumentu, włącznie z drukarką, która drukuje podczas drukowania z aplikacji Windows Forms.Specifies information about how a document is printed, including the printer that prints it, when printing from a Windows Forms application. |
PrinterSettings.PaperSizeCollection |
Zawiera kolekcję PaperSize obiektów.Contains a collection of PaperSize objects. |
PrinterSettings.PaperSourceCollection |
Zawiera kolekcję PaperSource obiektów.Contains a collection of PaperSource objects. |
PrinterSettings.PrinterResolutionCollection |
Zawiera kolekcję PrinterResolution obiektów.Contains a collection of PrinterResolution objects. |
PrinterSettings.StringCollection |
Zawiera kolekcję String obiektów.Contains a collection of String objects. |
PrinterUnitConvert |
Określa serię metod konwersji, które są przydatne podczas współdziałania z interfejsem API drukowania Win32.Specifies a series of conversion methods that are useful when interoperating with the Win32 printing API. Klasa ta nie może być dziedziczona.This class cannot be inherited. |
PrintEventArgs |
Dostarcza dane dla BeginPrint zdarzeń i EndPrint .Provides data for the BeginPrint and EndPrint events. |
PrintingPermission |
Kontroluje dostęp do drukarek.Controls access to printers. Klasa ta nie może być dziedziczona.This class cannot be inherited. |
PrintingPermissionAttribute |
Umożliwia sprawdzanie uprawnień do drukowania deklaratywnego.Allows declarative printing permission checks. |
PrintPageEventArgs |
Udostępnia dane dla zdarzenia PrintPage.Provides data for the PrintPage event. |
QueryPageSettingsEventArgs |
Udostępnia dane dla zdarzenia QueryPageSettings.Provides data for the QueryPageSettings event. |
StandardPrintController |
Określa Kontroler wydruku, który wysyła informacje do drukarki.Specifies a print controller that sends information to a printer. |
Wyliczenia
Duplex |
Określa ustawienie dupleksu drukarki.Specifies the printer's duplex setting. |
PaperKind |
Określa standardowe rozmiary papieru.Specifies the standard paper sizes. |
PaperSourceKind |
Standardowe źródła papieru.Standard paper sources. |
PrintAction |
Określa typ operacji drukowania.Specifies the type of print operation occurring. |
PrinterResolutionKind |
Określa rozdzielczość drukarki.Specifies a printer resolution. |
PrinterUnit |
Określa kilka jednostek miary używanych do drukowania.Specifies several of the units of measure used for printing. |
PrintingPermissionLevel |
Określa typ drukowania, które może wykonać kod.Specifies the type of printing that code is allowed to do. |
PrintRange |
Określa część dokumentu do wydrukowania.Specifies the part of the document to print. |
Delegaci
PrintEventHandler |
Reprezentuje metodę, która będzie obsługiwać BeginPrint zdarzenie lub EndPrint PrintDocument .Represents the method that will handle the BeginPrint or EndPrint event of a PrintDocument. |
PrintPageEventHandler |
Reprezentuje metodę, która będzie obsługiwać PrintPage zdarzenie typu PrintDocument .Represents the method that will handle the PrintPage event of a PrintDocument. |
QueryPageSettingsEventHandler |
Reprezentuje metodę, która obsługuje QueryPageSettings zdarzenie typu PrintDocument .Represents the method that handles the QueryPageSettings event of a PrintDocument. |
Uwagi
Zazwyczaj podczas drukowania z aplikacji Windows Forms należy utworzyć nowe wystąpienie PrintDocument klasy, ustawić właściwości, takie jak DefaultPageSettings i PrinterSettings , które opisują sposób drukowania i wywoływać Print metodę w celu rzeczywistego drukowania dokumentu.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. Wywołanie PrintDocument.Print metody wywołuje PrintDocument.PrintPage zdarzenie, które powinno zostać obsłużone w celu przeprowadzenia układu dokumentu do drukowania.Calling the PrintDocument.Print method raises the PrintDocument.PrintPage event, which should be handled to perform the document layout for printing.
Użyj Graphics właściwości PrintPageEventArgs obiektu uzyskanego ze PrintDocument.PrintPage zdarzenia, aby określić dane wyjściowe do wydrukowania.Use the Graphics property of the PrintPageEventArgs object obtained from the PrintDocument.PrintPage event to specify the output to print. Jeśli drukujesz plik tekstowy, użyj StreamReader do odczytu jednego wiersza w czasie ze strumienia i Wywołaj DrawString metodę, aby narysować linię w obiekcie Graphics.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. Aby uzyskać więcej informacji o tym procesie, zobacz Graphics StreamReader klasy i.For more information about this process, see the Graphics and StreamReader classes. Przykład drukowania dokumentu tekstowego można wyświetlić w PrintDocument temacie Omówienie klas.You can view an example of printing a text document in the PrintDocument class overview topic.
Uwaga
DrawTextMetody TextRenderer klasy nie są obsługiwane na potrzeby drukowania.The DrawText methods of the TextRenderer class are not supported for printing. Zamiast tego należy użyć DrawString metod Graphics klasy.Instead, use the DrawString methods of the Graphics class.
Po zaimplementowaniu w klasie pochodnej PrintController kontroluje sposób PrintDocument drukowania.When implemented in a derived class, the PrintController controls how a PrintDocument is printed. PrintDocument.PrintMetoda wywołuje OnStartPrint metody,, OnEndPrint OnStartPage , i,,, i OnEndPage , co z kolei informuje drukarkę, jak wydrukować dokument.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. Aby uzyskać więcej informacji o oknach dialogowych drukowania, zobacz PrintDialog i PageSetupDialog .For more information about printing dialog boxes, see PrintDialog and PageSetupDialog.
Proces drukowania w wersji zapoznawczej używa wyspecjalizowanego kontrolera wydruku, okna dialogowego i kontroli.The print-preview process uses a specialized print controller, dialog box, and control. Aby zapoznać się z przykładem takiego kontrolera wydruku i okna dialogowego, zobacz PreviewPrintController , PrintPreviewDialog i PrintPreviewControl .For an example of such a print controller and dialog box, see PreviewPrintController, PrintPreviewDialog, and PrintPreviewControl.
Przestroga
Klasy w System.Drawing.Printing przestrzeni nazw nie są obsługiwane do użycia w ramach usługi lub aplikacji ASP.NET lub usługi.Classes within the System.Drawing.Printing namespace are not supported for use within a Windows service or ASP.NET application or service. Próba użycia tych klas z poziomu jednego z tych typów aplikacji może spowodować nieoczekiwane problemy, takie jak obniżenie wydajności usługi i wyjątki czasu wykonywania.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.
Jeśli chcesz drukować z aplikacji Windows Presentation Foundation (WPF), zobacz System.Printing przestrzeń nazw.If you want to print from a Windows Presentation Foundation (WPF) application, see the System.Printing namespace.