Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing from an Applet

Status
Not open for further replies.

KEJinSC

Programmer
Sep 12, 2002
7
US
Hi,
I have an ASP application where I need to print a ticket to a client printer from within IE 6. I have started building a Java Applet that I can make calls to from Javascript. I would like to set properties of the object from within Javascript and then submit a print. Since this is a ticket, it will always be the same format except for certai pieces of data.

From within the applet, I can Lookup the default Print Service on the client pc (windows 2000) and would like to print there. I have a few questions that hopefully someone can help with.

1- Can I actually print from an Applet? I have read where I may need a signed applet. Is this possible for IE or is it a Netscape only thing?

Assuming I can actually print, here are some more:

2- Can I print without actually building a file on the client? I would like to simply send a stream of data to a printer from within my applet.

3- Does anyone have some sample code that will print from an applet? Most printing examples I have found are for applications and printing a pre-existing file.


I will be glad the beginnings of my applet and html if someone could help.

Thanks,
Keith
 
1) yes, you need a signed applet. And yes that's not just a Netscape thing. I don't use applets so don't ask me where to get it certified and signed (I guess there are companies that do it for a fee).
2) yes, that's usually the way printing works. Whether the operating system then creates a file that actually gets sent to the printer is out of your influence. You tell the JVM what to print which tells the print engine of the OS which tells the printer.
3) not me :) Whether you print an existing file or something from memory shouldn't matter. The same principles are involved, only the actual stream classes used are different. Same with application and applet. Just experiment, that's always the best way to learn. You are not going to learn by slavishly copying what someone else did for you, you learn by figuring it out for yourself.
 
Since I'm using the Java SDK 1.4.2, is there a way around the signed applet? This article seems to say there might be:
<a href=&quot;
I've been experimenting and am managing to make a little progress. I don't have very much Java experience so it is just taking alot of research for each new piece. What input stream type should be used for data that is in memory? Also, any info on formatting the document, such as fonts, orientation, positioning, etc?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top