:right-sidebar: True PrintJob =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: PrintJob(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` A ``GtkPrintJob`` object represents a job that is sent to a printer. You only need to deal directly with print jobs if you use the non-portable :obj:`~gi.repository.Gtk.PrintUnixDialog` API. Use :obj:`~gi.repository.Gtk.PrintJob.get_surface` to obtain the cairo surface onto which the pages must be drawn. Use :obj:`~gi.repository.Gtk.PrintJob.send` to send the finished job to the printer. If you don’t use cairo ``GtkPrintJob`` also supports printing of manually generated PostScript, via :obj:`~gi.repository.Gtk.PrintJob.set_source_file`. Constructors ------------ .. rst-class:: interim-class .. class:: PrintJob :no-index: .. classmethod:: new(title: str, printer: ~gi.repository.Gtk.Printer, settings: ~gi.repository.Gtk.PrintSettings, page_setup: ~gi.repository.Gtk.PageSetup) -> ~gi.repository.Gtk.PrintJob Creates a new ``GtkPrintJob``. :param title: the job title :param printer: a ``GtkPrinter`` :param settings: a ``GtkPrintSettings`` :param page_setup: a ``GtkPageSetup`` Methods ------- .. rst-class:: interim-class .. class:: PrintJob :no-index: .. method:: get_collate() -> bool Gets whether this job is printed collated. .. method:: get_n_up() -> int Gets the n-up setting for this job. .. method:: get_n_up_layout() -> ~gi.repository.Gtk.NumberUpLayout Gets the n-up layout setting for this job. .. method:: get_num_copies() -> int Gets the number of copies of this job. .. method:: get_page_ranges() -> list[~gi.repository.Gtk.PageRange] Gets the page ranges for this job. .. method:: get_page_set() -> ~gi.repository.Gtk.PageSet Gets the ``GtkPageSet`` setting for this job. .. method:: get_pages() -> ~gi.repository.Gtk.PrintPages Gets the ``GtkPrintPages`` setting for this job. .. method:: get_printer() -> ~gi.repository.Gtk.Printer Gets the ``GtkPrinter`` of the print job. .. method:: get_reverse() -> bool Gets whether this job is printed reversed. .. method:: get_rotate() -> bool Gets whether the job is printed rotated. .. method:: get_scale() -> float Gets the scale for this job. .. method:: get_settings() -> ~gi.repository.Gtk.PrintSettings Gets the ``GtkPrintSettings`` of the print job. .. method:: get_status() -> ~gi.repository.Gtk.PrintStatus Gets the status of the print job. .. method:: get_surface() -> ~gi.repository.cairo.Surface Gets a cairo surface onto which the pages of the print job should be rendered. .. method:: get_title() -> str Gets the job title. .. method:: get_track_print_status() -> bool Returns whether jobs will be tracked after printing. For details, see :obj:`~gi.repository.Gtk.PrintJob.set_track_print_status`. .. method:: send(callback: ~typing.Callable[[...], None], *user_data: ~typing.Any) -> None Sends the print job off to the printer. :param callback: function to call when the job completes or an error occurs :param user_data: user data that gets passed to ``callback`` .. method:: set_collate(collate: bool) -> None Sets whether this job is printed collated. :param collate: whether the job is printed collated .. method:: set_n_up(n_up: int) -> None Sets the n-up setting for this job. :param n_up: the n-up value .. method:: set_n_up_layout(layout: ~gi.repository.Gtk.NumberUpLayout) -> None Sets the n-up layout setting for this job. :param layout: the n-up layout setting .. method:: set_num_copies(num_copies: int) -> None Sets the number of copies for this job. :param num_copies: the number of copies .. method:: set_page_ranges(ranges: ~typing.Sequence[~gi.repository.Gtk.PageRange]) -> None Sets the page ranges for this job. :param ranges: pointer to an array of ``GtkPageRange`` structs .. method:: set_page_set(page_set: ~gi.repository.Gtk.PageSet) -> None Sets the ``GtkPageSet`` setting for this job. :param page_set: a ``GtkPageSet`` setting .. method:: set_pages(pages: ~gi.repository.Gtk.PrintPages) -> None Sets the ``GtkPrintPages`` setting for this job. :param pages: the ``GtkPrintPages`` setting .. method:: set_reverse(reverse: bool) -> None Sets whether this job is printed reversed. :param reverse: whether the job is printed reversed .. method:: set_rotate(rotate: bool) -> None Sets whether this job is printed rotated. :param rotate: whether to print rotated .. method:: set_scale(scale: float) -> None Sets the scale for this job. 1.0 means unscaled. :param scale: the scale .. method:: set_source_fd(fd: int) -> bool Make the ``GtkPrintJob`` send an existing document to the printing system. The file can be in any format understood by the platforms printing system (typically PostScript, but on many platforms PDF may work too). See :obj:`~gi.repository.Gtk.Printer.accepts_pdf` and :obj:`~gi.repository.Gtk.Printer.accepts_ps`. This is similar to :obj:`~gi.repository.Gtk.PrintJob.set_source_file`, but takes expects an open file descriptor for the file, instead of a filename. :param fd: a file descriptor .. method:: set_source_file(filename: str) -> bool Make the ``GtkPrintJob`` send an existing document to the printing system. The file can be in any format understood by the platforms printing system (typically PostScript, but on many platforms PDF may work too). See :obj:`~gi.repository.Gtk.Printer.accepts_pdf` and :obj:`~gi.repository.Gtk.Printer.accepts_ps`. :param filename: the file to be printed .. method:: set_track_print_status(track_status: bool) -> None If track_status is :const:`True`, the print job will try to continue report on the status of the print job in the printer queues and printer. This can allow your application to show things like “out of paper” issues, and when the print job actually reaches the printer. This function is often implemented using some form of polling, so it should not be enabled unless needed. :param track_status: :const:`True` to track status after printing Properties ---------- .. rst-class:: interim-class .. class:: PrintJob :no-index: .. attribute:: props.page_setup :type: ~gi.repository.Gtk.PageSetup Page setup. .. attribute:: props.printer :type: ~gi.repository.Gtk.Printer The printer to send the job to. .. attribute:: props.settings :type: ~gi.repository.Gtk.PrintSettings Printer settings. .. attribute:: props.title :type: str The title of the print job. .. attribute:: props.track_print_status :type: bool :const:`True` if the print job will continue to emit status-changed signals after the print data has been setn to the printer. Signals ------- .. rst-class:: interim-class .. class:: PrintJob.signals :no-index: .. method:: status_changed() -> None Emitted when the status of a job changes. The signal handler can use :obj:`~gi.repository.Gtk.PrintJob.get_status` to obtain the new status.