Solved

Printing HTML file to a selected printer

Posted on 2006-06-27
15
210 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
 
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now