Link to home
Start Free TrialLog in
Avatar of riaancornelius
riaancornelius

asked on

Printing HTML file to a selected printer

I am displaying a (generated) HTML file. Basically it's an overview of all the info a user entered in a wizard. So there is no physical HTML file, only a String which I display as HTML in a JEditorPane.

How do I let the user select a printer and then print this file to that printer? Also, the HTML contains a table with a width of 100% how do I make sure that the HTML prints correctly on any size paper?

Thanks
Avatar of riaancornelius
riaancornelius

ASKER

OK, I've found how you can get a print service by using javax.print, So just need to know how I print?
Avatar of girionis
that's printing using java.awt.printing. As far as I  can see, that will only print to the default printer. I need to know how to print an HTML formatted string to the user specified printer.

I've seen how to use javax.print to select a printer, So I just need to know how to print HTML formatted text using javax.print
> As far as I  can see, that will only print to the default printer

It will print to the printer you have previously selected.
>> It will print to the printer you have previously selected.

And how do you select a printer?
Using a PrinterJob you will get a dialog with the available printers. Then you select the printer you want from there.
Actually, It seems the simple answer is that it can't be done natively. The longer answer is that HTML can be printed like this:

http://forum.java.sun.com/thread.jspa?forumID=20&threadID=215404
Requesting that question be deleted...
I would suggest PAQ and points refudned.
Agreed. Didn't think about the fact that there is actually a solution in here. :)
I am fine with this :)
ASKER CERTIFIED SOLUTION
Avatar of GhostMod
GhostMod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial