Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

printing: A4/letter problem

 
Kai Witte
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

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.

Kai
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

http://forum.java.sun.com/thread.jspa?threadID=614808
 
Kai Witte
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,

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.

Kai
 
Kai Witte
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

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).

Kai
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic