Navigate
Home
ArticleWiki
Forum
Journal
Search
Newsletter
Links
Tech News
expertsrt.com
Welcome Guest.
Username:

Password:

Remember me

Sending output to printer in PHP
Welcome, Guest. Please login or register.
August 29, 2008, 03:47:04 PM
11291 Posts in 1243 Topics by 838 Members
Latest Member: gjpino
Experts Round Table Network  |  Serverside Technology  |  PHP  |  Sending output to printer in PHP « previous next »
Pages: [1]
Author Topic: Sending output to printer in PHP  (Read 418 times)
thepreacher

Offline Offline

Posts: 76


« on: May 18, 2008, 12:17:57 AM »

I need to provide the functionality for a receipt (A5) to be printed out on a printer. I am looking to have a button where when its click on the printer dialog will be invoked or better still it will just print to the printer.

At the moment we us the browser print option.

PS. I use only PHP and JavaScript.
Logged
CrYpTiC_MauleR
Site Builder

Offline Offline

Posts: 487



WWW
« Reply #1 on: May 18, 2008, 09:26:23 AM »

You can uses JavaScript's window.print() to make the browser print, doesn't even have to have user interaction, can print on page display or whenever you need. I am not sure what dialogs if any it might invoke on the operating system though, so there might be a confirmation dialog for print properties or something. You can also take a look at http://us.php.net/manual/en/book.printer.php might need an additional extension to be added to your PHP install.
Logged

[x] Fight | www.crypticmauler.com
"You must be
VGR
Mentor

Offline Offline

Posts: 680



WWW
« Reply #2 on: May 19, 2008, 10:45:08 AM »

yes, it's the only way unless you want to start playing with Int21h or redirection to PRN ... from javascript ;-)

My suggestion in your case is to display a frameset with the pint button in one and the A5 receipt in the other. Printing will be very easy & efficient (the button's frame will not get printed). This way, your receipt can be displayed under any form (HTML, PDF...)

I once had to generate on the fly and printout automatically, and possibily without any printer dialog, dynamic data. I had a web page already built. I passed through obscure javascript involving a DIV dynamicallt generated in memory, with its contents being filled in from the main document... Not what you want, for sure ;-)
Logged

techie overlord, answers all kind of questions on http://www.europeanexperts.org
Pages: [1]
« previous next »
    Jump to: