• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Printing

 
Ranch Hand
Posts: 838
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have checked this topic out before posting this and I have found nothing relevant to what I'm trying to do. I have a main page that (upon clicking a button) opens another window with another HTML in it. I want to send the contents of this other HTML document (i.e. the one in the new window) directly to a printer. This application is not running over the web but, rather, is running locally on an intranet. I've used the print() method to try printing to the printer but that comes up with the print dialog box and I don't want that. I know at one point before, the print() method (in IE) did print to the printer and then closed. I had a close() method inserted shortly after the window print() method was called and that closed the window and the print was called. Now, the same scenario doesnt occur. After the print method is called the dialog stays up.
Is there a way to directly call the same code as what is called by the browsers print button and not the print option under file?
Would WSH be the best alternative?
Is there any other options available here?
Thanks in advance for any response.
Rob
 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, there is a link, that solves your problem.
It is Windows IE only, and I tryed it in my IE5.5:
http://www.faqts.com/knowledge_base/view.phtml/aid/9169
This is the code I tryed:
<SCRIPT LANGUAGE="JAVASCRIPT">
function ieExecWB( intOLEcmd, intOLEparam )
{
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
if ( ( ! intOLEparam ) || ( intOLEparam < -1 ) || (
intOLEparam > 1 ) )
intOLEparam = 1;
WebBrowser1.ExecWB( intOLEcmd, intOLEparam );
WebBrowser1.outerHTML = "";
}
</script>
<button on_Click="ieExecWB(6, -1)">
Print Me! - No Prompt!
</button>
 
Rob Hunter
Ranch Hand
Posts: 838
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Yuriy,
Thanks for the response but I have already tried code similar to that and it didnt work. Before I tried to open the new window and then a print() and then a close() (if it were IE). It had worked at one point (eons ago) and now it doesnt. I have an HTML page for a bunch of things and depending on certain conditions a different page will print so I was hoping, first of all, to send the contents of the page 'directly' to the printer but that doesnt seem easily possible. So when I use :
new_win = window.open(.... does the code you posted still work for the new page just opened? I mean new_win.document. and then whatver objects. If this doesnt seem like something meant for javascript in this way do you know anything about WSH? I understand that things are a bit diificult over the web but this is a local application so I knew there have to be ways to accomplish this. Thanks so much for the help. Hopefully you have another idea on the tip of your brain. Thanks again.
Rob
 
Yuriy Fuksenko
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is this page, that you want to print, yours, or it is just taken from internet? Is it in the same domain?
 
Rob Hunter
Ranch Hand
Posts: 838
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Yuriy,
The computer running this application will not have access to the outside world, probably not even the local network.
Rob
 
Rob Hunter
Ranch Hand
Posts: 838
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Again,
Sorry I misunderstand where the app was going. The application will be running on a server about 4-6 computers on the network will be running this application. Each computer will have its own printer connected and therefore will need to print to its own printer. I've tried the code posted by Yuriy above and it seems to work fine but it appears that the page prints to the printer attached to the server. This printer is indeed shared and added to the printer group of every printer in question but the default printer is set up as the printer directly connected to each computer. Am I leaving something out here? Any help would be GREATLY appreciated. Thanks.
Rob
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic