?
Solved

Printing HTML file to a selected printer

Posted on 2006-06-27
15
Medium Priority
?
217 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
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 …
Suggested Courses
Course of the Month15 days, 10 hours left to enroll

743 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