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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

automatic print

Status
Not open for further replies.

marknav

Programmer
Sep 26, 2002
14
0
0
US
I want to print a page automatically. the user will press submit and the information will be printed and then submited,without making the user click anything else.
(so I don't want to use the window.print())
Also I want to make sure that if the page was not printed then the page will not be submitted.
Can anyone help?
Thank you
 
You could probably do that in on onSubmit event handler in your form.

Code:
<head>
   :
<script ...>
    function printMyPage(){
             :
          window.print();
             :
          return true;
    }
</script>
</head>

<body>
   <form ... onSubmit=&quot;return printMyPage();&quot;>
         :
      <input type=&quot;submit&quot; ...>
   </form>
</body>

the trick is the later part of your question... how to make sure that the page was printed. By this I'm guessing you mean you want to know if someone cancelled the print dialog. I don't know of a way to do this, unless the print() method returns true/false (I don't think it does, but you'll need to experiment). Then you could do something like:
Code:
<script ...>
    function printMyPage(){
             :
          return window.print();
    }
</script>




-Carl
 
are you sure that by writing :
<script ...>
function printMyPage(){
:
window.print();
:
return true;
}
</script>
The user will not have to be involved in clicking on the print dialog? (I want the page to be printed immediately afetr clicking the submit).
As for the second part, what I ment: if the page was not printed, not due to cancellation of the user ( because he is not involved) but due to -for ex - printer error.

 
Ah... now I see what you're asking.

No, window.print() will bring up the print dialog. I have seen sites that somehow bypass the print dialog... but I have no idea how they do it... and I can't seem to find one now that I'm looking. I'm guessing that they used a servlet, applet, or OCX to do it.

Because the built-in javascript methods insist that you show the print dialog, and rightly so. Otherwise, if this wasn't the case, anyone on the web could send anything they wanted to my printer (imagine a 110 page document) without giving me the ability to decline/cancel (or at least select my desired destination printer and printer properties)... which would really annoy the vast majority of users.

Can you imagine where spam would go if, everytime you hit a site, instead of 6 pop-up ads you got 6 printed ads rattled off to your printer without so much as a user prompt?

Bad news.

That said, I did find this page:
it appears to use an OCX object... but it doesn't seem to work with my browser... perhaps the later browsers prevent this action? One can only hope.





-Carl
 
Hello, I'm also looking for a way to print directly to avoid the print dialogue using coldfusion.

i was wondering how the cold fusion studio object accomplished it, or by callling an com object or if an http post of some sort could do the trick.

also the page you suggested is no longer available.

i did find this one, but same problem doesn't work from my machine - nt4


any ideas? thx, Jeff


Jeffrey E. Moeller
 
why? is there no chance at all that the users printer might not be ready to print, or might need settings changed? or is there not going to be any user available, but the doc needs to be printed anyways? I'm not sure i've ever been in a situation where the user could not click &quot;PRINT&quot;



 
you have to understand the mobile paradigm. pocket pc does not have print capabilities, therefore the server side language used for the browser apps has to handle direct printing.

it turns out an easy way to deal with this is to have the server side dump the file into a directory that is monitored by a server process which sends to the print driver when found.

Jeffrey E. Moeller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top