Solved

Printing HTML file to a selected printer

Posted on 2006-06-27
15
215 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

Technology Partners: 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!

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…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

707 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