I have no answer, but I will try to explain why this is happening and why it will not be easy to fix. This behavior seems to depend on the specifications of the Internet Printing Protocol (IPP) and is due to how IPP is implemented by the Java print service API (to which the JavaFX print job is delegated). The following is a snippet from the Oracles technical note that explains the limitations of manually setting the paper source ( https://docs.oracle.com/javase/8/docs/technotes/guides/jps/spec/attributes.fm5.html ):
Media is an IPP attribute that identifies the medium on which printing is. The Media attribute is an important attribute to understand, but is relatively complex.
The Java print service API defines three subclasses of the abstract Media class to reflect the overloaded Media attribute in the IPP specification: MediaSizeName, MediaName, and MediaTray. All subclasses of Media have a category of Media, for which each subclass defines different standard attribute values. [...]
The value of the Media attribute is always a string, but since the attribute is overloaded, its value determines the type of media to which the attribute belongs. For example, a predefined set of IPP attribute values ββincludes the values ββ"a4" and "top-tray". If the Media parameter is set to "a4", the Media attribute refers to the paper size, but if the Media parameter is set to "top-tray", the Media attribute refers to the paper source. [...]
In most cases, applications will use either MediaSizeName or MediaTray. The MediaSizeName class lists media by size. The MediaTray class lists the paper trays on the printer, which typically includes the main tray and the manual feed tray. The IPP 1.1 specification does not provide for the simultaneous indication of both the size of the media and the media tray, which means, for example, that the application cannot request A4 paper from the bypass tray. A future revision of the IPP specification may provide a way to request more than one type of media at a time, in which case the JPS API is likely to be expanded to implement this change.
So, MediaTray (or paper source) is not an independent parameter and cannot be set if the Media attribute is already defined in one of two other ways ( MediaSizeName or MediaName ). This is exactly what happens with the page setup dialogs.
J2DPrinterJob class (from the com.sun.prism.j2d.print package) contains the dialogue code and updates the print job settings (I found this while debugging your application). The following is a method of this class that updates the paper source setting in the dialog box.
private void updatePaperSource() { Media m = (Media)printReqAttrSet.get(Media.class); if (m instanceof MediaTray) { PaperSource s = j2dPrinter.getPaperSource((MediaTray)m); if (s != null) { settings.setPaperSource(s); } } }
I tested different scenarios, and the result was the same: by the time updatePaperSource() started, the Media attribute was already defined as MediaSizeName . Therefore, instructions in the if branches are never executed, so the paper source is not updated.
I suspect that the paper type or paper size takes precedence over the paper source, and since the page setup dialog always determines the paper type (there is no "Automatic option"), it overloads the paper source selection to avoid an attribute conflict. This essentially makes this option useless.
It could be a bug in the JDK or an intentional design decision. In any case, I donβt see an easy way to solve this problem while in JavaFX, given that it comes from private methods in the internal Javas API.