3

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.

Lijimol v r
  • 31
  • 1
  • 1
  • 5

2 Answers2

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

Pascut
  • 3,291
  • 6
  • 36
  • 64
  • Yes, this is open source: https://github.com/Asprise/scannerjs.javascript-scanner-access-in-browsers-chrome-ie.scanner.js – Pascut Dec 05 '17 at 12:36
  • scanner.js is not open source – flysakura Dec 06 '17 at 01:27
  • 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? – Pascut Dec 07 '17 at 09:12
  • I want the PHP to send a command to invoke the scanner for scanning papers. – Lijimol v r Dec 07 '17 at 09:50
  • How can i use phpSANE in windows system.? – Lijimol v r Dec 13 '17 at 10:03
  • 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: https://www.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. – Pascut Dec 14 '17 at 12:27
1

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.
Shafiq al-Shaar
  • 1,292
  • 14
  • 22