I am using the DocumentRenderer by Kei G. Gauthier to print the content of a JEditorPane. I always force the print dialog to be displayed prior to printing.
Most of the time everything works as expected. In an environment somewhere else, which I cannot reproduce or simulate here, it always tries to print letter format (that's what the physical printer claims). This is independent of wether or not the user chooses A4 (the default on the system) in the print dialog.
Since I cannot reproduce the problem here, I can't just try different approaches. I have to modify the process so that it works right away, without testing.
What can I do? I don't see any place in the API that has to do with the paper format. java.awt.print.Paper#setSize seems to be close to that, but it seems unlikely to me that it computes the "analog" settings to a predefined format like A4.
I know zip about printing, but here's a link to a print program posted in sun's forums (works well) the relevant bits seem to be lines 111 to 120 this may not have any bearing on your problem, but it's worth a look
the comments in that example could be interpreted so that setting to A4 is done by specifying the A4 width and height manually in the Paper after all. Since I can't try it and only have one attempt, I'll continue my investigation, but maybe that is the solution.
it worked as you said: Using Paper#setSize(594.936, 841.536) actually makes the printer use A4 paper. I did not expect this; I thought it would be some constant like MediaSize.A4 in javax.print (the newer print API; since 1.4).