.. include:: headings.inc .. _Printer: ========================================================================================================================================== |phoenix_title| **Printer** ========================================================================================================================================== This class represents the Windows or PostScript printer, and is the vehicle through which printing may be launched by an application. Printing can also be achieved through using of lower functions and classes, but this and associated classes provide a more convenient and general method of printing. .. seealso:: :ref:`Printing Framework Overview `, :ref:`PrinterDC`, :ref:`PrintDialog`, :ref:`Printout`, :ref:`PrintPreview` | |class_hierarchy| Inheritance Diagram ===================================== Inheritance diagram for class **Printer** .. raw:: html

Inheritance diagram of Printer

| |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~Printer.__init__` Constructor. :meth:`~Printer.CreateAbortWindow` Creates the default printing abort window, with a cancel button. :meth:`~Printer.GetAbort` Returns ``True`` if the user has aborted the print job. :meth:`~Printer.GetLastError` Return last error. :meth:`~Printer.GetPrintDialogData` Returns the :ref:`print data ` associated with the printer object. :meth:`~Printer.Print` Starts the printing process. :meth:`~Printer.PrintDialog` Invokes the print dialog. :meth:`~Printer.ReportError` Default error-reporting function. :meth:`~Printer.Setup` Invokes the print setup dialog. ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~Printer.Abort` See :meth:`~Printer.GetAbort` :attr:`~Printer.PrintDialogData` See :meth:`~Printer.GetPrintDialogData` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: Printer(Object) This class represents the Windows or PostScript printer, and is the vehicle through which printing may be launched by an application. **Possible constructors**:: Printer(data=None) .. method:: __init__(self, data=None) Constructor. Pass an optional pointer to a block of print dialog data, which will be copied to the printer object's local data. :param `data`: :type `data`: PrintDialogData .. seealso:: :ref:`PrintDialogData`, :ref:`PrintData` .. method:: CreateAbortWindow(self, parent, printout) Creates the default printing abort window, with a cancel button. :param `parent`: :type `parent`: Window :param `printout`: :type `printout`: Printout :rtype: :ref:`Window` .. method:: GetAbort(self) Returns ``True`` if the user has aborted the print job. :rtype: `bool` .. staticmethod:: GetLastError() Return last error. Valid after calling :meth:`Print` , :meth:`PrintDialog` or :meth:`PrintPreview.Print` . These functions set last error to ``PRINTER_NO_ERROR`` if no error happened. Returned value is one of the following: ======================== ====================================== ``PRINTER_NO_ERROR`` No error happened. ``PRINTER_CANCELLED`` The user cancelled printing. ``PRINTER_ERROR`` There was an error during printing. ======================== ====================================== | :rtype: :ref:`PrinterError` .. method:: GetPrintDialogData(self) Returns the :ref:`print data ` associated with the printer object. :rtype: :ref:`PrintDialogData` .. method:: Print(self, parent, printout, prompt=True) Starts the printing process. Provide a parent window, a user-defined :ref:`Printout` object which controls the printing of a document, and whether the print dialog should be invoked first. :meth:`Print` could return ``False`` if there was a problem initializing the printer device context (current printer not set, for example) or the user cancelled printing. Call :meth:`GetLastError` to get detailed information about the kind of the error. :param `parent`: :type `parent`: Window :param `printout`: :type `printout`: Printout :param `prompt`: :type `prompt`: bool :rtype: `bool` .. method:: PrintDialog(self, parent) Invokes the print dialog. If successful (the user did not press Cancel and no error occurred), a suitable device context will be returned; otherwise ``None`` is returned; call :meth:`GetLastError` to get detailed information about the kind of the error. :param `parent`: :type `parent`: Window :rtype: :ref:`DC` .. note:: The application must delete this device context to avoid a memory leak. .. method:: ReportError(self, parent, printout, message) Default error-reporting function. :param `parent`: :type `parent`: Window :param `printout`: :type `printout`: Printout :param `message`: :type `message`: string .. method:: Setup(self, parent) Invokes the print setup dialog. :param `parent`: :type `parent`: Window :rtype: `bool` .. note:: The setup dialog is obsolete from Windows 95, though retained for backward compatibility. .. attribute:: Abort See :meth:`~Printer.GetAbort` .. attribute:: PrintDialogData See :meth:`~Printer.GetPrintDialogData`