Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8269642

javafx printing: Support Specifying Print to File in the API

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: openjfx17
    • Component/s: javafx
    • Labels:
      None
    • Subcomponent:
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      New API
    • Interface Kind:
      Java API
    • Scope:
      JDK

      Description

      Summary

      Provide API to enable programmatically specifying that printed content should be directed to a spool file, not the printer.

      Problem

      In cases such as if the program is printing without user interaction or using a custom print dialog, there is currently no way to specify that output should go to a file. This is particularly useful when the printer driver generates some format such as PDF which may be then distributed or viewed.

      Solution

      Add to the existing JobSettings class, a new JavaFX string property which is the name of the destination spool file.

      This can be used to both specify the output file and query the current output file, if any.

      Specification

      public class javafx.print.JobSettings  :
      
          /**
           * A {@code StringProperty} representing the
           * name of a filesystem file, to which the platform printer
           * driver should spool the rendered print data.
           *
           * Applications can use this to programmatically request print-to-file
           * behavior where the native print system is capable of spooling the
           * output to a filesystem file, rather than the printer device.
           *
           * This is often useful where the printer driver generates a format
           * such as Postscript or PDF, and the application intends to distribute
           * the result instead of printing it, or for some other reason the
           * application does not want physical media (paper) emitted by the printer.
           *
           * The default value is an empty string, which is interpreted as unset,
           * equivalent to null, which means output is sent to the printer.
           * So in order to reset to print to the printer, clear the value of
           * this property by setting it to null or an empty string.
           *
           * Additionally if the application displays a printer dialog which allows
           * the user to specify a file destination, including altering an application
           * specified file destination, the value of this property will reflect that
           * user-specified choice, including clearing it to reset to print to
           * the printer, if the user does so.
           *
           * If the print system does not support print-to-file, then this
           * setting will be ignored.
           *
           * If the specified name specifies a non-existent path, or does not specify
           * a user writable file, when printing the results are platform-dependent.
           * Possible behaviours might include replacement with a default output file location,
           * printing to the printer instead, or a platform printing error.
           * If a {@code SecurityManager} is installed and it denies access to the
           * specified file a {@code SecurityException} may be thrown.
           *
           * @defaultValue an empty string
           *
           * @return the name of a printer spool file
           * @since 17
           */
          public final StringProperty outputFileProperty();
      
          public String getOutputFile();
      
          public void setOutputFile(String filePath);
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              prr Philip Race
              Reporter:
              prr Philip Race
              Reviewed By:
              Kevin Rushforth
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: