Class PrintJob

All Implemented Interfaces:
PointerInterface

public class PrintJob extends 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 [class@Gtk.PrintUnixDialog] API.

Use [method@Gtk.PrintJob.get_surface] to obtain the cairo surface
onto which the pages must be drawn. Use [method@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 [method@Gtk.PrintJob.set_source_file].

https://docs.gtk.org/gtk4/class.PrintJob.html

  • Field Details

  • Constructor Details

    • PrintJob

      public PrintJob(PointerContainer pointer)
    • PrintJob

      public PrintJob(@Nonnull Str title, @Nonnull Printer printer, @Nonnull PrintSettings settings, @Nonnull PageSetup page_setup)
      Creates a new `GtkPrintJob`.
      Parameters:
      title - the job title
      printer - a `GtkPrinter`
      settings - a `GtkPrintSettings`
      page_setup - a `GtkPageSetup`
    • PrintJob

      public PrintJob(String title, @Nonnull Printer printer, @Nonnull PrintSettings settings, @Nonnull PageSetup page_setup)
      Creates a new `GtkPrintJob`.
      Parameters:
      title - the job title
      printer - a `GtkPrinter`
      settings - a `GtkPrintSettings`
      page_setup - a `GtkPageSetup`
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • getCollate

      public boolean getCollate()
      Gets whether this job is printed collated.
      Returns:
      whether the job is printed collated
    • getNUp

      public int getNUp()
      Gets the n-up setting for this job.
      Returns:
      the n-up setting
    • getNUpLayout

      public int getNUpLayout()
      Gets the n-up layout setting for this job.
      Returns:
      the n-up layout
    • getNumCopies

      public int getNumCopies()
      Gets the number of copies of this job.
      Returns:
      the number of copies
    • getPageSet

      public int getPageSet()
      Gets the `GtkPageSet` setting for this job.
      Returns:
      the `GtkPageSet` setting
    • getPages

      public int getPages()
      Gets the `GtkPrintPages` setting for this job.
      Returns:
      the `GtkPrintPages` setting
    • getPrinter

      public Printer getPrinter()
      Gets the `GtkPrinter` of the print job.
      Returns:
      the printer of @job
    • getReverse

      public boolean getReverse()
      Gets whether this job is printed reversed.
      Returns:
      whether the job is printed reversed.
    • getRotate

      public boolean getRotate()
      Gets whether the job is printed rotated.
      Returns:
      whether the job is printed rotated
    • getScale

      public double getScale()
      Gets the scale for this job.
      Returns:
      the scale
    • getSettings

      public PrintSettings getSettings()
      Gets the `GtkPrintSettings` of the print job.
      Returns:
      the settings of @job
    • getStatus

      public int getStatus()
      Gets the status of the print job.
      Returns:
      the status of @job
    • getSurface

      public Surface getSurface() throws AllocationError
      Gets a cairo surface onto which the pages of
      the print job should be rendered.
      Returns:
      the cairo surface of @job
      Throws:
      AllocationError
    • getTitle

      public Str getTitle()
      Gets the job title.
      Returns:
      the title of @job
    • getTrackPrintStatus

      public boolean getTrackPrintStatus()
      Returns whether jobs will be tracked after printing.

      For details, see [method@Gtk.PrintJob.set_track_print_status].
      Returns:
      %TRUE if print job status will be reported after printing
    • send

      public void send(PrintJob.OnPrintJobCompleteFunc callback, @Nullable Pointer user_data, PrintJob.OnDestroyNotify dnotify)
      Sends the print job off to the printer.
      Parameters:
      callback - function to call when the job completes or an error occurs
      user_data - user data that gets passed to @callback
      dnotify - destroy notify for @user_data
    • setCollate

      public void setCollate(boolean collate)
      Sets whether this job is printed collated.
      Parameters:
      collate - whether the job is printed collated
    • setNUp

      public void setNUp(int n_up)
      Sets the n-up setting for this job.
      Parameters:
      n_up - the n-up value
    • setNUpLayout

      public void setNUpLayout(int layout)
      Sets the n-up layout setting for this job.
      Parameters:
      layout - the n-up layout setting
    • setNumCopies

      public void setNumCopies(int num_copies)
      Sets the number of copies for this job.
      Parameters:
      num_copies - the number of copies
    • setPageSet

      public void setPageSet(int page_set)
      Sets the `GtkPageSet` setting for this job.
      Parameters:
      page_set - a `GtkPageSet` setting
    • setPages

      public void setPages(int pages)
      Sets the `GtkPrintPages` setting for this job.
      Parameters:
      pages - the `GtkPrintPages` setting
    • setReverse

      public void setReverse(boolean reverse)
      Sets whether this job is printed reversed.
      Parameters:
      reverse - whether the job is printed reversed
    • setRotate

      public void setRotate(boolean rotate)
      Sets whether this job is printed rotated.
      Parameters:
      rotate - whether to print rotated
    • setScale

      public void setScale(double scale)
      Sets the scale for this job.

      1.0 means unscaled.
      Parameters:
      scale - the scale
    • setSourceFd

      public boolean setSourceFd(int fd) throws AllocationError
      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 [method@Gtk.Printer.accepts_pdf] and
      [method@Gtk.Printer.accepts_ps].

      This is similar to [method@Gtk.PrintJob.set_source_file],
      but takes expects an open file descriptor for the file,
      instead of a filename.
      Parameters:
      fd - a file descriptor
      Returns:
      %FALSE if an error occurred
      Throws:
      AllocationError
    • setSourceFile

      public boolean setSourceFile(@Nonnull Str filename) throws AllocationError
      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 [method@Gtk.Printer.accepts_pdf] and
      [method@Gtk.Printer.accepts_ps].
      Parameters:
      filename - the file to be printed
      Returns:
      %FALSE if an error occurred
      Throws:
      AllocationError
    • setSourceFile

      public boolean setSourceFile(String filename) throws AllocationError
      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 [method@Gtk.Printer.accepts_pdf] and
      [method@Gtk.Printer.accepts_ps].
      Parameters:
      filename - the file to be printed
      Returns:
      %FALSE if an error occurred
      Throws:
      AllocationError
    • setTrackPrintStatus

      public void setTrackPrintStatus(boolean track_status)
      If track_status is %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.
      Parameters:
      track_status - %TRUE to track status after printing
    • onStatusChanged

      public SignalHandler onStatusChanged(PrintJob.OnStatusChanged signal)
      Connect to signal "status-changed".
      See PrintJob.OnStatusChanged.onStatusChanged() for signal description.
      Field SIGNAL_ON_STATUS_CHANGED contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()