Author: Juan Camacho
Viewers: 36
Package: PHP Scan Document
The NAPS2 program is an Open Source software tool available in several operating systems like Linux, Windows, and Mac OS X.
Read this article to learn how to use the PHP NAPS2 wrapper class to simplify automated document scanning from PHP.
In this article you will learn:
1. Introduction
2. What is the NASP2 PHP Class Wrapper
3. How to Use the NASP2 PHP Class Wrapper
4. Download or Install the NAPS2 Wrapper Class Using PHP Composer
5. Conclusion
1. Introduction
Scanning printed documents is a common task in various types of applications. NASP2 is a popular open-source scanning tool with a command-line interface for automating the scanning process.
This article explores a PHP class wrapper for NASP2 that simplifies document scanning by encapsulating the command-line options within easy-to-use methods.
2. What is the NASP2 PHP Class Wrapper
The NASP2 PHP Class Wrapper is a PHP class that wraps around the NASP2 command-line interface, allowing developers to interact with the NASP2 program using simple method calls.
The class provides methods corresponding to each option available in the NASP2 command-line documentation, making it straightforward to configure the scanning process.
3. How to Use the NASP2 PHP Class Wrapper
To get started, download and install NASP2 from the official website. Once installed, include the Naps2Wrapper.php
file in your PHP project.
Instantiate the Naps2Wrapper
class by providing the path to the naps2.console
executable:
$wrapper = new Naps2Wrapper('/path/to/naps2.console');
Scan a document by calling the scan()
method with the desired output path:
$output = $wrapper->scan('/path/to/output.pdf');
echo $output;
Set specific options before scanning using dedicated methods. For example, to specify the scanner, resolution, and color mode:
$output = $wrapper->scanner('MyScanner')->resolution(300)->color('Gray')->scan('/path/to/output.pdf');
echo $output;
You can chain multiple method calls to set multiple options simultaneously. Additionally, the class supports other options mentioned in the NASP2 command-line documentation, such as the source and OCR language.
4. Download or Install the NAPS2 Wrapper Class Using PHP Composer
This package can be installed in two ways One way is the traditional that consists in downloading the package files from the download page.
The other way is more modern which consists in installing the package from the PHP Classes site Composer repository. To install using PHP composer, you need to follow the instructions from the download page and use the Install with Composer button.
5. Conclusion
The NASP2 PHP Class Wrapper simplifies document scanning using NASP2 by encapsulating the command-line options within easy-to-use methods.
By leveraging this wrapper class, developers can seamlessly integrate NASP2 into their PHP applications and easily automate the scanning process.
The class offers flexibility in setting various options, enabling customization according to specific scanning requirements.
To get started, download the NASP2 PHP Class Wrapper from GitHub repository link, and refer to the provided documentation for detailed usage instructions.
You need to be a registered user or login to post a comment
1,616,107 PHP developers registered to the PHP Classes site.
Be One of Us!
Login Immediately with your account on:
Comments:
No comments were submitted yet.