set Destination attribute in printReqAttrSet

Neacsu Cristian neacsu.cristianstefan at
Fri May 10 08:39:21 UTC 2019

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");
PrinterJobImpl jobImpl = (PrinterJobImpl) field.get(job);
field = jobImpl.getClass().getDeclaredField("printReqAttrSet");
PrintRequestAttributeSet printReqAttrSet = (PrintRequestAttributeSet)
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?

More information about the openjfx-dev mailing list