How can i invoke a paper scanner using php code?

10,723

Solution 1

PHP is a server side language and cannot interact with client side hardware. You can use a web-based TWAIN SDK to scan documents in your PHP app. Check out this article which might help: http://www.dynamsoft.com/blog/document-imaging/how-to-scan-documents-in-php

You can also use Scanner.js: https://github.com/Asprise/scannerjs.javascript-scanner-access-in-browsers-chrome-ie.scanner.js

Maybe you can try phpSANE: https://sourceforge.net/projects/phpsane/

phpSANE is a web-based frontend for SANE written in HTML/PHP so you can scan with your web-browser. It also supports OCR.

PHP Printer library: https://github.com/mike42/escpos-php

Solution 2

I was in a similar position as you and found there were 0 open-source libraries.

Thus, I created a library https://github.com/spacemudd/webagent-scanner.

What you need to do:

  • Install Python 2.7.
  • Navigate to webagent-scanner's root folder and run: python setup.py py2exe
  • In dist/ and open app.exe. This will create a localhost web server w/ port 8087.
  • In your web application, ensure the user has app.exe running.
  • Use Javascript to make a GET request to https://localhost:8087/scan
  • The response of the GET request... you inject it in a form to send it to your PHP backend.
Share:
10,723
Admin
Author by

Admin

Updated on July 24, 2022

Comments

  • Admin
    Admin almost 2 years

    How can I invoke a paper scanner using php code?

    I have already used Dynamic Web TWAIN for scanning, but it is not free.

    I need an open source code to scan.

    Please help me. Thank you in advance.

  • Pascut
    Pascut over 6 years
    Yes, this is open source: github.com/Asprise/…
  • flysakura
    flysakura over 6 years
    scanner.js is not open source
  • Pascut
    Pascut over 6 years
    I added a new library example in my answer. Please detail what you want to print. You have some pdf/txt file that you want to print directly from PHP? You want the PHP to send a command to the printer?
  • Admin
    Admin over 6 years
    I want the PHP to send a command to invoke the scanner for scanning papers.
  • Admin
    Admin over 6 years
    How can i use phpSANE in windows system.?
  • Pascut
    Pascut over 6 years
    The question that you are actually asking is how to run PHP on windows. Because phpSANE is just a PHP script. You should use IIS or XAMP/MAMP. You can find a tutorial here: youtube.com/watch?v=N6ENnaRotmo that explains how to install PHP, Apache and MySql on windows. By the way, latest PHP version is 7.2, I suggest you to use that version. Good luck.