Jump to content
farukweb

how to pos print directly press button

Recommended Posts

I am making a pos(point of sale) application using object oriented php.

I have found thermal receipt printers support ESC/POS .

i want that when i will press button to print directly , it will do automatically. 

anyone can help me please.

Thanks in advance. 

Share this post


Link to post
Share on other sites

What kind of a button?  A physical one that is connected to your device?  Or an HTML submit button?  What have you tried in code so far?

 

Help us to help you.  We will if you have a question about code!

Share this post


Link to post
Share on other sites
6 hours ago, ginerjm said:

What kind of a button?  A physical one that is connected to your device?  Or an HTML submit button?  What have you tried in code so far?

 

Help us to help you.  We will if you have a question about code!

this is html submit button. 

when i will submit form, it will hit pos printer directly .

Share this post


Link to post
Share on other sites

Are you running PHP on your local machine or on a remote server?

Share this post


Link to post
Share on other sites

I am running on local machine now. later i will move to live server.

can you understand my issues?

 

Share this post


Link to post
Share on other sites

HOw is this printer device connected so that your server will be able to talk to it?

Share this post


Link to post
Share on other sites

I can print easily from my pc connected with usb pos machine.I have installed driver , so that it works fine. 

EscPos.php

try {
    // Enter the device file for your USB printer here
    // You can check the tutorial here: https://mike42.me/blog/2015-03-getting-a-usb-receipt-printer-working-on-linux
    $connector = new FilePrintConnector("/dev/usb/lp0");
    /* Print a "Hello world" receipt" */
    $printer = new Printer($connector);
    $printer -> text("Hello World!\n");
    $printer -> cut();
    /* Close printer */
    $printer -> close();
} catch (Exception $e) {
    echo "Couldn't print to this printer: " . $e -> getMessage() . "\n";
}

myform.php 

when i submitted a form data , it is redirecting escpos.php for printing and it prints. 

but i don't want like that. 

I want when i will submit form, it will be print directly current page  without redirecting to escpos.php. 

 

 

Share this post


Link to post
Share on other sites

Just move the printer code to your myform.php, assuming that is the target of the form post.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.