Printing to thermal/pos printer frm php

5,142 views
Skip to first unread message

Daniel Bamigbayan

unread,
May 18, 2012, 5:44:44 AM5/18/12
to lagos...@googlegroups.com
Hi all,
I need to print from one of my php apps to a thermal printer. Has anyone done this before. Just need some quick hints that'll guide my research on this subject cos it has to be implemented asap.

Thanks in advance


Regards,
Daniel Bamigbayan

Femi TAIWO

unread,
May 18, 2012, 5:50:09 AM5/18/12
to lagos...@googlegroups.com
Hi Daniel,

Quick questions:
More info would be useful - 



1. Is the printer connected to the Webserver(Apache) machine or just to the system with the web browser?

2. Windows or Linux Server?

 

Regards,

Femi TAIWO



--
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

[ Lagos GTUG Quicklinks ]
Mailing List:http://bit.ly/lagosgtuggroup
Twitter Handle: http://twitter.com/@gtuglagos
Blog: http://bit.ly/lagosgtug
G+: http://bit.ly/lagosgtugplus
---_---_---_---_---_---_---_---_---_---_---_---_---_---_---_-

You received this message because you are subscribed to the Google
Groups "Lagos GTUG" group.
To post to this group, send email to lagos...@googlegroups.com
To unsubscribe from this group, send email to
lagos-gtug+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/lagos-gtug?hl=en

Daniel Bamigbayan

unread,
May 18, 2012, 5:54:48 AM5/18/12
to lagos...@googlegroups.com
Hi Femi,

U'r amazing. Thanks for d prompt response. The printer will be connected to a windows based system. I Don't know about connecting it to apache. Like I said, I'v nt tried this before, but I'm convincd its no biggie.

Thanks

Regards,
Daniel Bamigbayan

From: Femi TAIWO <dft...@gmail.com>
Date: Fri, 18 May 2012 10:50:09 +0100
Subject: Re: {Lagos GTUG} Printing to thermal/pos printer frm php

Femi TAIWO

unread,
May 18, 2012, 6:17:42 AM5/18/12
to lagos...@googlegroups.com
Hi Daniel,

Possible options


1. Send raw data to the printer from PHP - use file_put_contents or fopen to send to send data to the printer directly. This would work on a printer shared on the network as well. I recommend this option actually - 
fopen is a really powerful tool. It can do wonders. 

2. If the machine running your application is a windows machine and is connected to the printer, you should look at using  ActiveX Controls with PHP.


3.
.
.
.
n
 
Possible Hack: 
If the printer is normally accessible from notepad or wordpad or other applications on the machine, then you could call create a text file and do something like 

<?php shell_exec("notepad /P C:\receipt.txt"); ?> 
which would send the document to the default printer for printing.











Regards,

Femi TAIWO

Jason Jolaoso

unread,
May 18, 2012, 6:08:49 AM5/18/12
to lagos...@googlegroups.com, prude...@gmail.com
:-)

Working on something similar as we speak but am tweaking a usb POS/Thermal printer

Try
javascripts window.print() if you like the easy way out

but if you are like me who thrives on sweat and hardwork visit:


http://www.ehow.com/how_10073205_use-php-thermal-printer.html
http://php.net/manual/en/ref.printer.php

Best of luck man.

On Fri, May 18, 2012 at 10:44 AM, Daniel Bamigbayan <prude...@gmail.com> wrote:

Daniel Bamigbayan

unread,
May 18, 2012, 6:21:59 AM5/18/12
to Jason Jolaoso, jayob...@gmail.com, lagos...@googlegroups.com
@femi - just got u right. D printer will be connected directly to d server. But what differentiates d two options in case there is d need to do that in df future

@Jason,

Thank. Simply means it's no different frm printing to a regular printer cos I already use d javascript option. I'll chk out d other links. Thanks.

One more question, does d receipt automatically resize to d size of d pos receipt or a different css has to be written to handle that.

Thanks gtug.I think I'm almost done wit my coding just on d way back frm client meeting

Regards,
Daniel Bamigbayan

From: Jason Jolaoso <ja...@siltech.com.ng>
Date: Fri, 18 May 2012 11:08:49 +0100
Subject: Re: {Lagos GTUG} Printing to thermal/pos printer frm php

Femi TAIWO

unread,
May 18, 2012, 6:23:23 AM5/18/12
to lagos...@googlegroups.com
@Jason - You're the man!
Regards,

Femi TAIWO

Tope Faro

unread,
May 18, 2012, 6:29:00 AM5/18/12
to lagos...@googlegroups.com
Nice work guys. #TeamHelpOneAnother (Y)

Abiodun Thorpe

unread,
May 18, 2012, 6:33:09 AM5/18/12
to lagos...@googlegroups.com
Yikes!! I like this.
Website: www.abiodunthorpe.com.ng
Twitter: @tpcast
Blog: www.tech360ng.com


Note: Privileged/Confidential information may be contained in this message and may be subject to legal privilege. Access to this e-mail by anyone other than the intended is unauthorised. If you are not the intended recipient (or responsible for delivery of the message to such person), you may not use, copy, distribute or deliver to anyone this message (or any part of its contents ) or take any action in reliance on it. In such case, you should destroy this message, and notify me immediately. If you have received this email in error, also please notify me immediately by e-mail or telephone and delete the e-mail from any computer. 

All reasonable precautions have been taken to ensure no viruses are present in this e-mail. However, Abiodun Thorpe cannot guarantee that e-mail communications are secure or error-free, as information could be intercepted, corrupted, amended, lost, destroyed, arrive late or incomplete, or contain viruses.

Jason Jolaoso

unread,
May 18, 2012, 6:53:53 AM5/18/12
to prude...@gmail.com, lagos...@googlegroups.com
Nice work guys

@Daniel you might need to play around with your css and formatting

Also From my experience once you install the printer/( printer driver if need be) windows selects the best fit for the thermal printer setting.

Use windows print page test to confirm this.

Got to run will talk more later.

Folalola

unread,
May 18, 2012, 4:48:42 PM5/18/12
to Jason Jolaoso, prude...@gmail.com, lagos...@googlegroups.com

Abisagbo Segun

unread,
May 19, 2012, 10:43:23 AM5/19/12
to lagos...@googlegroups.com
I had this challenge once and femi has given a bery good answer.

A key thing you need to do is convert to PDF/PostScript... Languages
the printer understands naturally.

Also specify measurements via CSS, the use DOM2PDF to convert ur HTML to PDF.

Download ghostprint and ghostview

install both...
Then use <?php exec('path-to-gs.exe filename.pdf')?>

Abisagbo Segun

unread,
May 19, 2012, 10:45:15 AM5/19/12
to lagos...@googlegroups.com
DOM2PDF, ghostprint etc are all free to download...

Just google...
Reply all
Reply to author
Forward
0 new messages