PHP Classes

PHP Scan Document: Scan and process scanned documents with NAPS2

Recommend this page to a friend!
  Info   View files Documentation   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (2)    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 120 All time: 9,500 This week: 71Up
Version License PHP version Categories
php-scan-naps2 1.0.0MIT/X Consortium ...5Email, PHP 5, Graphics, Files and Fol..., P...


This package can scan and process scanned documents with NAPS2.

It can use the NAPS2 program to access a scanner device to scan printed documents and save the scanned document to a PDF file.

The package can also process PDF document files in several ways:

- Send email messages with the PDF files attached to the messages

- Import additional PDF files to combine with the scanned PDF document and generate a single PDF file

- Convert images to PDF documents

Innovation Award
PHP Programming Innovation award winner
August 2023
Many applications need to use documents that have been printed and process the documents in a way they can be stored as files.

There are scanner devices that can be used to convert printed documents to PDF files.

The conversion process is complex because there are many types of scanner devices.

One way to simplify this process is to use specialized programs that communicate with almost any device.

NAPS2 is one of those programs. It can work in different operating systems.

This package can communicate with NAPS2 to utilize its capabilities to scan printed documents and convert them into PDF files.

Manuel Lemos
Picture of Juan Camacho
  Performance   Level  
Name: Juan Camacho <contact>
Classes: 5 packages by
Country: Spain Spain
Age: 45
All time rank: 4070110 in Spain Spain
Week rank: 228 Up13 in Spain Spain Up
Innovation award
Innovation award
Nominee: 2x

Winner: 1x




php-scan is a PHP class that provides a convenient wrapper for interacting with NAPS2 (Not Another PDF Scanner 2) console functionality. - Aditional info: Command line usage

Table of Contents


  • Simplified PHP wrapper for NAPS2 console functionality.
  • Set output file path and format for scanned documents.
  • Specify email options to send scans as attachments.
  • Import one or more PDF/image files to include in the output.
  • Combine multiple files together into a single output file.
  • Convert files between different formats.
  • Set recipient(s), subject, and body for email sending.
  • Enable or disable OCR (Optical Character Recognition) for PDF generation.
  • Set scanning profile and verbosity level.
  • Control the number of scans to perform and the delay between each scan.
  • Force overwrite of existing files.
  • Slice and select specific pages to scan.
  • Set PDF metadata options such as title, author, subject, and keywords.
  • Adjust JPEG quality for image conversion.
  • Specify TIFF compression options.
  • Control interleave and deinterleave options for scanning.
  • Reverse the order of pages in the output.
  • Set placeholders for missing metadata.
  • Compatible with PHP 5.6 or above and NAPS2 installation.


Install the package using Composer:

composer require kuasarx/php-scan



use PhpScan\phpScan;

// Create an instance of the phpScan class
$naps2 = new phpScan();

// Set the output file path

// Set other options as needed

// Set the email option to specify an email with the scan attached

// Set the import option to specify one or more PDF/image files to import

// Combine multiple files together into a single output file
$naps2->setCombineFiles('file1.pdf;file2.pdf', 'combined.pdf');

// Convert a file from one format to another
$naps2->setConvertFile('input.jpg', 'output.pdf');

// Set the email recipient(s)

// Set the email subject and body
$naps2->setSubject('Scanned Document');
$naps2->setBody('Please find the attached scanned document.');

// Set options for automatic email sending

// Set OCR language for PDF generation

// Set the scanning profile
$naps2->setProfile('Scanner Profile');

// Set verbosity to display progress information

// Set the number of scans to perform

// Set the delay between each scan (in milliseconds)

// Set the force option to overwrite existing files

// Set the slice option to specify a range of pages to scan

// Set PDF metadata options
$naps2->setPdfTitle('My Document');
$naps2->setPdfAuthor('John Doe');
$naps2->setPdfKeywords('keyword1, keyword2');

// Set JPEG quality for image conversion

// Set TIFF compression option

// Set interleave and deinterleave options

// Set the reverse option to reverse the order of pages

// Set placeholders for missing metadata

// Build the command
$command = $naps2->buildCommand();

// Run the command
$output = $naps2->scan();

// Process the output as needed


  • PHP 5.6 or above
  • NAPS2 installed and configured

  Files folder image Files  
File Role Description
Files folder imagesrc (1 file)
Plain text file composer.json Data Auxiliary data
Plain text file LICENSE Lic. License text
Plain text file Doc. Read me

  Files folder image Files  /  src  
File Role Description
  Plain text file phpScan.php Class Class source

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:9,500
This week:71Up