in reply to Print to a printer

No I am sorry that i didn't explain what i want exactly. I am using ActivePerl and I have a button on my html page that when clicked should print the current page to the printer. So i need to write some cgi script using modules.

Replies are listed 'Best First'.
RE: Re: Print to a printer
by Fastolfe (Vicar) on Nov 02, 2000 at 03:22 UTC
    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.

      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.

        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().