How to automaticly print from the web

Posted on 2005-03-17
Medium Priority
Last Modified: 2008-01-09
I know this has been asked, but I have researched this and found that either the links are old and not valid any more, or I simply don't understand them.
I built an Web application that I would like it to print to a printer after the user clicks on a recieve button.  So when the user recieves in a item, the application does it's thing to the database, then I want a label to come out of the printer, with little or no other user interaction.  I have heard of a javascript that pops up the print dialog box for you on a page.  I am looking to see if I can go beyond that, and have it print automaticly.  It is a intranet site with IE 6, on a coldfusion server.   Any ideas, good links, advice, or examples?

What I was thinking was the application to pop up a single window with only the information I want to print and it prints it automaticly and then close

I have everything working except for the print part.  I know what I need to print, which by the way is a small table with some fields.  This will be a specific single user feature to print, but I would like to keep this on the web, instead of building another interface(ie Access with VBA coding).  Thanks in advanced.
Question by:Meps
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

Razix earned 600 total points
ID: 13570317

open a new window via popup or new target in a href and in that page call "window.print();" in the onload portion of the body tag. when this page is opened it will automatically try to print. good luck.

<title>Print This Page</title>
<body OnLoad="window.print();" >


LVL 53

Assisted Solution

COBOLdinosaur earned 75 total points
ID: 13570406
This is avner's solution from another thread:

The only way to do this , is using Active X :
<script language="javascript1.2">
<!-- copyright(c) avcoh@yahoo.com
function print() {
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);

execScript("on error resume next: WebBrowser1.ExecWB 6, 0", "VBScript");
execScript('on error resume next: WebBrowser1.outerHTML = ""', 'VBScript');

<body onload="print()">
hello world

That's been around for a while so I don't know if it works with XP SP2, ehcih tighten up quite few activex holes.

LVL 51

Expert Comment

by:Ted Bouskill
ID: 13572203
Thankfully for security reasons the operating system will NOT give the browser full control of the printing process.  The user will have to respond to the print dialog box.

Pop ups are bad enough, imagine if a website could print without permission by the user?  Imagine the spam!

Assisted Solution

neu-rah earned 75 total points
ID: 13573555
<script>window.print()</script> at the end of the page or on the onload method of page body will do

Author Comment

ID: 13590494
Thanks everyone for your replies, sorry I was directed to do something last week.  I will be testing everyone's ideas, and then hopefully award points.  Again, thanks

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Suggested Courses

764 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