RFR: 8223717: javafx printing: Support Specifying Print to File in the API [v2]
Kevin Rushforth
kcr at openjdk.java.net
Thu Jun 24 22:42:06 UTC 2021
On Thu, 24 Jun 2021 22:34:36 GMT, Phil Race <prr at openjdk.org> wrote:
>> This enhancement adds the String property outputFileProperty() to the JobSettings class.
>> The value should be a string that references a local file encoded as a URL.
>> If this is non-null and set to a location that the user has permission to write to,
>> then the printer output will be spooled there instead of the printer, so long as the platform printing system supports this.
>> The user can of course also set a print-to-file destination in the platform printer dialogs which may over-ride what the application set. But now the application can also see what it was set to, and cancel or alter it if necessary.
>>
>> A simple manual test is provided, manual mainly because the few real printing functional tests are all manual as they are only useful if run with a printer configured.
>
> Phil Race has updated the pull request incrementally with two additional commits since the last revision:
>
> - 8223717: javafx printing: Support Specifying Print to File in the API
> - 8223717: javafx printing: Support Specifying Print to File in the API
I left some preliminary comments on the API spec.
modules/javafx.graphics/src/main/java/javafx/print/JobSettings.java line 474:
> 472: * encoded name of a filesystem file, to which the platform printer
> 473: * driver should spool the rendered print data.
> 474: * <p>
Can you add a sentence indicating that the URL needs to be a `file:` URL? And indicate what happens if it isn't (I presume it is ignored)?
modules/javafx.graphics/src/main/java/javafx/print/JobSettings.java line 475:
> 473: * driver should spool the rendered print data.
> 474: * <p>
> 475: * Applications can use this to request print-to-file behaviour where
behaviour -> behavior
modules/javafx.graphics/src/main/java/javafx/print/JobSettings.java line 488:
> 486: * If the print system does not support print-to-file, then this
> 487: * <p>
> 488: * setting will be ignored.
These two lines should be switched.
modules/javafx.graphics/src/main/java/javafx/print/JobSettings.java line 490:
> 488: * setting will be ignored.
> 489: * If the URL specifies a non-existent path, or does not specify
> 490: * a writable file it may be ignored, or a SecurityException may be thrown.
I want to look at what we do for other properties like this. I'm not sure how feasible it is to throw an exception back to the application. And I wouldn't want to single out a security exception (what about a read-only file system?). I think that whatever the reason, if the file can't be written to, we should treat it consistently. Probably by ignoring the request. I presume that's what will happen if the print driver doesn't support print-to-file?
modules/javafx.graphics/src/main/java/javafx/print/JobSettings.java line 495:
> 493: *
> 494: * @return the name of a printer spool file
> 495: * @since 13
17
-------------
PR: https://git.openjdk.java.net/jfx/pull/543
More information about the openjfx-dev
mailing list