in reply to Re: Print to a printer
in thread Print to a printer

Still not 100% sure what you're asking here. With CGI, Perl is a server-side scripting language. A button on your web page, if posting to a CGI script, would execute the Perl script on the server, which is the only place Perl can initiate a print function. So if this is the route you can go, a user hitting a web page and clicking on a Print button would post a form to your CGI script, and your CGI script would presumably print something on the server, not the client's printer.

If you're wanting to put a button on an HTML page that prints the current page in the client's printer (as if the user clicked on File | Print in their browser), you can't do this with Perl. Consider JavaScript or some ActiveX/Java component that would communicate with the browser and initiate a print command that way. Perl can't directly interact with a browser. All it does in a CGI context is return content to the browser, typically in the form of an HTML page.

If I'm misunderstanding, by all means elaborate.

Replies are listed 'Best First'.
RE: RE: Re: Print to a printer
by Anonymous Monk on Nov 02, 2000 at 03:45 UTC
    Thanks a lot for the help. The explanation was nice and clear. But I have one more question is that what do you use NET::Printer what exactly does that module do.
      If a Perl script wishes to interact with a printer on the network (hence Net::Printer) that speaks the Unix standard 'lpd' protocols, this is the module it would use. It's equivalent to some module that would let you use a network or locally installed printer under Windows.

      Again, this is all local to where the script is being run. If the user/system that the script resides has no means to print to an arbitrary printer, a Perl script using this or any other module isn't going to be able to either. This has nothing to do with stuff on the client side.

        thanks a lot for all the help
        thanks a lot for all the help
      How can you send attachments to email. I used sendmail to send emails. I was trying to use MIME::Lite to send attachments but it is giving me an error when i use the attach().
        That would be a perfectly acceptable way of doing what you're trying to do. Perhaps if you told us what the error was, we could help you.

        If you're not on a Unix system or otherwise don't have the standard "sendmail" program to handle your 'send' request, the MIME::Lite documentation recommends something like this instead:

        MIME::Lite->send('smtp', "smtp.myisp.net", Timeout=>60); $msg->send;
        Otherwise, you're going to have to be a lot more verbose and specific about the problem you're having.