Solved

Printing HTML file to a selected printer

Posted on 2006-06-27
15
212 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

785 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