Everything you are touching there pre-supposes knowledge of today's implementation of the JavaFX printing API, so I don't think we can endorse that. The right thing to do (maybe years ago!) is to file an RFE to request that something like the Destination attribute be supported in the FX printing API. I've reviewed the open bug list and I don't see that anyone else has asked for this.
I just submitted : https://bugs.openjdk.java.net/browse/JDK-8223717 JFYI, I reviewed some old notes and it was originally planned to be supported in the API but during design discussion it was removed as a result of a combination of getting it right, not being sure how many people would need it (you may be the first) and some perhaps over-stated concerns about security. -phil. On 5/10/19, 1:39 AM, Neacsu Cristian wrote:
For windows print through "Microsoft Print to PDF", there is no way right now to pre-define a path programmatically. There is no way to set inside the printReqAttrSet (J2DPrinterJob), an attribute of type Destination, to solve this issue. Before jdk 9, I was bypassing it through reflection like this: java.lang.reflect.Field field = job.getClass().getDeclaredField("jobImpl"); field.setAccessible(true); PrinterJobImpl jobImpl = (PrinterJobImpl) field.get(job); field.setAccessible(false); field = jobImpl.getClass().getDeclaredField("printReqAttrSet"); field.setAccessible(true); PrintRequestAttributeSet printReqAttrSet = (PrintRequestAttributeSet) field.get(jobImpl); field.setAccessible(false); printReqAttrSet.add(new Destination(new File(filePath).toURI())); Now, the module is closed, so I cannot access it through reflection. Is there a way to obtain this behavior again?