File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes printing: A4/letter problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "printing: A4/letter problem" Watch "printing: A4/letter problem" New topic
Author

printing: A4/letter problem

Kai Witte
Ranch Hand

Joined: Jul 17, 2004
Posts: 356
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


Kai Witte's business website Kai Witte's private homepage
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
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

Joined: Jul 17, 2004
Posts: 356
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

Joined: Jul 17, 2004
Posts: 356
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: printing: A4/letter problem