• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

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
0
riaancornelius
Asked:
riaancornelius
  • 7
  • 6
1 Solution
 
riaancorneliusAuthor Commented:
OK, I've found how you can get a print service by using javax.print, So just need to know how I print?
0
 
girionisCommented:
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
riaancorneliusAuthor Commented:
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
0
 
girionisCommented:
> As far as I  can see, that will only print to the default printer

It will print to the printer you have previously selected.
0
 
riaancorneliusAuthor Commented:
>> It will print to the printer you have previously selected.

And how do you select a printer?
0
 
girionisCommented:
Using a PrinterJob you will get a dialog with the available printers. Then you select the printer you want from there.
0
 
girionisCommented:
0
 
riaancorneliusAuthor Commented:
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
0
 
riaancorneliusAuthor Commented:
Requesting that question be deleted...
0
 
girionisCommented:
I would suggest PAQ and points refudned.
0
 
riaancorneliusAuthor Commented:
Agreed. Didn't think about the fact that there is actually a solution in here. :)
0
 
girionisCommented:
I am fine with this :)
0
 
GhostModCommented:
Closed, 500 points refunded.
GhostMod
Community Support Moderator
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now