Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Printing to a Printer  RSS feed

 
Rob Hunter
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know of a way to include a java applet in an HTML page (or any script for that matter) that can take a string (stored in the page) and send it directly to the clients default printer?
I would like to store a string in the page and use that (if its reasonable). Im using a CGI application (written in Perl) that generates HTML pages but I need to include some type of client-side script or so forth to handle the local stuff. I wanted to include a Print button on one of those pages for the user to be able to click and send the accumulated information (shopping cart contents) to the user's local default printer. I was wondering if Javascript and/or Java Applets would be totally out of the question or not for handling this? If it is then what would be a good alternative to using these languages? I realize that Javascript is about useless and Java applets (due to IO security) cant due much in the way of file maintenance and, especially, creating Print Jobs (at least that was my assumption). Any help would be greatly appreciated.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rob,
Applets are probably not a viable consideration because of the "sandbox", that dirty little place that SecurityManagers force our poor little applets to run. The only way that you can get to local resources thru an applet is if there is policy file that grant's those permissions. In a corporate intranet, that wouldn't be a problem, but if you want your applet used by random surfers, you have a big problem.
Hope this helps
Michael Morris
SCJP2
 
Rob Hunter
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael,
I thought that might be the case but it was very much desired by a customer of ours. I was wondering, however, if there was any type of workaround that I could use (i.e. calling a Visual Basic executable to do the work for me)? They should really think of renaming "sandbox" to "quicksand hole" . Thanks for your quick response.
Rob
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rob,
ActiveX is probably your best bet here. It's pretty simple to create an ActiveX control in VB, so if you're comfortable with VB, that's what I'd do. You're still going to have to deal with popping up a window to install your control on the client's machine on the first occurance. That generally means getting a signed certificate from VeriSign if you want surfers to take you seriously.
If your application is targeted to a particular group (eg a single corporation), then applets may still be an option. You just have to make sure that all client machines have an appropriate permission entry in the system security file to allow your applet to access the local printer.
Hope this helps
Michael Morris
SCJP2
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!