Class PrintJob

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class PrintJob extends GObject

Represents a job that is sent to a printer.

You only need to deal directly with print jobs if you use the non-portable PrintUnixDialog API.

Use getSurface() to obtain the cairo surface onto which the pages must be drawn. Use send(PrintJobCompleteFunc) to send the finished job to the printer. If you don’t use cairo GtkPrintJob also supports printing of manually generated PostScript, via setSourceFile(String).

  • Constructor Details

    • PrintJob

      public PrintJob(MemorySegment address)
      Create a PrintJob instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • PrintJob

      public PrintJob(String title, Printer printer, PrintSettings settings, PageSetup pageSetup)
      Creates a new GtkPrintJob.
      Parameters:
      title - the job title
      printer - a GtkPrinter
      settings - a GtkPrintSettings
      pageSetup - a GtkPageSetup
    • PrintJob

      public PrintJob()
      Create a new PrintJob.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the PrintJob class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected PrintJob asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • 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 NumberUpLayout 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
    • getPageRanges

      public PageRange[] getPageRanges()
      Gets the page ranges for this job.
      Returns:
      a pointer to an array of GtkPageRange structs
    • getPageSet

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

      public PrintPages 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 this PrintJob
    • 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 this PrintJob
    • getStatus

      public PrintStatus getStatus()
      Gets the status of the print job.
      Returns:
      the status of this PrintJob
    • getSurface

      public org.freedesktop.cairo.Surface getSurface() throws GErrorException
      Gets a cairo surface onto which the pages of the print job should be rendered.
      Returns:
      the cairo surface of this PrintJob
      Throws:
      GErrorException - see GError
    • getTitle

      public String getTitle()
      Gets the job title.
      Returns:
      the title of this PrintJob
    • getTrackPrintStatus

      public boolean getTrackPrintStatus()

      Returns whether jobs will be tracked after printing.

      For details, see setTrackPrintStatus(boolean).

      Returns:
      true if print job status will be reported after printing
    • send

      public void send(@Nullable PrintJobCompleteFunc callback)
      Sends the print job off to the printer.
      Parameters:
      callback - function to call when the job completes or an error occurs
    • 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 nUp)
      Sets the n-up setting for this job.
      Parameters:
      nUp - the n-up value
    • setNUpLayout

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

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

      public void setPageRanges(@Nullable PageRange @Nullable [] ranges)
      Sets the page ranges for this job.
      Parameters:
      ranges - pointer to an array of GtkPageRange structs
    • setPageSet

      public void setPageSet(PageSet pageSet)
      Sets the GtkPageSet setting for this job.
      Parameters:
      pageSet - a GtkPageSet setting
    • setPages

      public void setPages(PrintPages 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 GErrorException

      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 Printer.acceptsPdf() and Printer.acceptsPs().

      This is similar to setSourceFile(String), 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:
      GErrorException - see GError
    • setSourceFile

      public boolean setSourceFile(String filename) throws GErrorException

      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 Printer.acceptsPdf() and Printer.acceptsPs().

      Parameters:
      filename - the file to be printed
      Returns:
      false if an error occurred
      Throws:
      GErrorException - see GError
    • setTrackPrintStatus

      public void setTrackPrintStatus(boolean trackStatus)

      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:
      trackStatus - true to track status after printing
    • onStatusChanged

      Emitted when the status of a job changes.

      The signal handler can use getStatus() to obtain the new status.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitStatusChanged

      public void emitStatusChanged()
      Emits the "status-changed" signal. See onStatusChanged(PrintJob.StatusChangedCallback).
    • builder

      public static PrintJob.Builder<? extends PrintJob.Builder> builder()
      A PrintJob.Builder object constructs a PrintJob with the specified properties. Use the various set...() methods to set properties, and finish construction with PrintJob.Builder.build().
      Returns:
      the builder object