RFR: 8223717: javafx printing: Support Specifying Print to File in the API [v3]
Phil Race
prr at openjdk.java.net
Mon Jun 28 19:47:44 UTC 2021
On Fri, 25 Jun 2021 04:08:30 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
>> Phil Race has updated the pull request incrementally with one additional commit since the last revision:
>>
>> 8223717: javafx printing: Support Specifying Print to File in the API
>
> modules/javafx.graphics/src/main/java/com/sun/prism/j2d/print/J2DPrinterJob.java line 352:
>
>> 350: try {
>> 351: settings.setOutputFile(dest.getURI().toURL().toString());
>> 352: } catch (MalformedURLException e) {
>
> I guess in 2D RasterPrinterJob, if there is any exception, we try to form a default file "out.prn" [https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java#L1137]
> and try to print there. Can't we do it here too?
I am going to just change to support file so this becomes a non-issue
> modules/javafx.graphics/src/main/java/com/sun/prism/j2d/print/J2DPrinterJob.java line 356:
>
>> 354: } else {
>> 355: settings.setOutputFile("");
>> 356: }
>
> Actually in 2D , it seems if dest is null, we redirect printing to actual printer instead of file. Not sure if that is what we need to do here too!!
> [https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java#L1148]
that is what we are doing ..
> modules/javafx.graphics/src/main/java/javafx/print/JobSettings.java line 485:
>
>> 483: * <p>
>> 484: * If the application does not have permission to write to the specified
>> 485: * file, a {@code SecurityException} may be thrown when printing.
>
> As I see in 2D atleast in Win32PrintService, if there is a SecurityException for creating a Destination object from a URI, it retries again by creating a new URL with default file "file:out.prn"
> Is it not needed here?
> [https://github.com/openjdk/jdk/blob/master/src/java.desktop/windows/classes/sun/print/Win32PrintService.java#L1181]
No. We are doing our own checking if a SM is running and disallow it.
-------------
PR: https://git.openjdk.java.net/jfx/pull/543
More information about the openjfx-dev
mailing list