Solved

Printing HTML file to a selected printer

Posted on 2006-06-27
15
213 Views
Last Modified: 2010-03-31
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
Comment
Question by:riaancornelius
  • 7
  • 6
15 Comments
 
LVL 9

Author Comment

by:riaancornelius
ID: 16990543
OK, I've found how you can get a print service by using javax.print, So just need to know how I print?
0
 
LVL 35

Expert Comment

by:girionis
ID: 16990567
0
 
LVL 35

Expert Comment

by:girionis
ID: 16990572
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 9

Author Comment

by:riaancornelius
ID: 16990590
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
 
LVL 35

Expert Comment

by:girionis
ID: 16990608
> 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
 
LVL 9

Author Comment

by:riaancornelius
ID: 16990628
>> It will print to the printer you have previously selected.

And how do you select a printer?
0
 
LVL 35

Expert Comment

by:girionis
ID: 16990643
Using a PrinterJob you will get a dialog with the available printers. Then you select the printer you want from there.
0
 
LVL 35

Expert Comment

by:girionis
ID: 16990651
0
 
LVL 9

Author Comment

by:riaancornelius
ID: 16991128
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
 
LVL 9

Author Comment

by:riaancornelius
ID: 16991134
Requesting that question be deleted...
0
 
LVL 35

Expert Comment

by:girionis
ID: 16991153
I would suggest PAQ and points refudned.
0
 
LVL 9

Author Comment

by:riaancornelius
ID: 16991162
Agreed. Didn't think about the fact that there is actually a solution in here. :)
0
 
LVL 35

Expert Comment

by:girionis
ID: 16998926
I am fine with this :)
0
 
LVL 1

Accepted Solution

by:
GhostMod earned 0 total points
ID: 17025456
Closed, 500 points refunded.
GhostMod
Community Support Moderator
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
diffSum example 4 53
hibernate insert example 13 34
login form jsp example 2 38
maven disable workspace resolution 1 24
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
The viewer will learn how to implement Singleton Design Pattern in Java.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question