Jump to content

[SOLVED] Auto print to default printer


Recommended Posts

I have an application running on Windows XP & IE7 which currently displays a screen of information and then uses javascript self.print(); to print same to locally connected printer. Two things wrong with this and they are:-

1) I want my application to print directly to the default printer without the Windows select printer dialog coming up and

2) I really dont need to display the screen. All the user wants is a printout, receipt.

 

Suggestions please.

Link to comment
Share on other sites

Sorry, I did not explain myself clearly enough. The user has already on a previous screen clicked print.

 

Clicked "print" as in your button on your webpage? All you can do is help them by bringing up the dialog. You can't skip the Window's print dialog.

 

If you are looking to do something like Google Maps, where they have a print button, which when clicked brings up a new webpage window, and once the new webpage is loaded, it automatically shows the print dialog, just add this between your HEAD tags on your popup:

<script type="text/javascript">
window.onload=function(){window.print()};
</script>

Link to comment
Share on other sites

The thing that is confusing me is that there is a C# application on the client(this is an intranet) that prints directly to the default printer without involving the Window's print dialog and the user want their webapp to do the same.

Link to comment
Share on other sites

The C app runs in a COM environment, which has access to print things directly. You're web app runs in a browser, which restricts that. The reason:

 

With a C app, the person should know what the program does before running it. But with a web app, people browsing the web can come across any site. If the browser allowed websites to auto-print without prompting, I could code my site to print thousands of pages of garbage whenever someone visited it. That wouldn't be very good would it?

 

Now, the SERVER hosting the webapp could automatically print stuff by executing some server side code (PHP or C or something). But not the client.

Link to comment
Share on other sites

  • 1 year later...

I wanted to send my thanks to rhodesa for the explanation and ask question again considering any new developments and capabilities through php integration with javascript or ActivX.

 

I understand the limitation & concern but there is still a legitimate need for quickly printing an html report that is generated on click of a button and sent to the pre-defined default printer on client side while bypassing the print dialog.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.