PHP Classes

PHP Scan Document: Scan and process scanned documents with NAPS2

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

Author

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
Winner
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: 4042109 in Spain Spain
Week rank: 44 Up2 in Spain Spain Up
Innovation award
Innovation award
Nominee: 2x

Winner: 1x

Documentation

php-scan

License

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

Features

  • 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.

Installation

Install the package using Composer:

composer require kuasarx/php-scan

Usage

<?php

use PhpScan\phpScan;

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

// Set the output file path
$naps2->setOutput('/path/to/output.pdf');

// Set other options as needed

// Set the email option to specify an email with the scan attached
$naps2->setEmail('filename.pdf');

// Set the import option to specify one or more PDF/image files to import
$naps2->setImport('file1.pdf;file2.pdf');

// 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)
$naps2->setTo('recipient@example.com');
$naps2->setCc('cc@example.com');
$naps2->setBcc('bcc@example.com');

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

// Set options for automatic email sending
$naps2->setAutoSend(true);
$naps2->setSilentSend(true);

// Set OCR language for PDF generation
$naps2->setOcrLanguage('eng');
$naps2->enableOcr();
$naps2->disableOcr();

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

// Set verbosity to display progress information
$naps2->setVerbose(true);

// Set the number of scans to perform
$naps2->setNumberOfScans(5);

// Set the delay between each scan (in milliseconds)
$naps2->setDelay(5000);

// Set the force option to overwrite existing files
$naps2->setForce(true);

// Set the slice option to specify a range of pages to scan
$naps2->setSlice('1-3');

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

// Set JPEG quality for image conversion
$naps2->setJpegQuality(90);

// Set TIFF compression option
$naps2->setTiffCompression('lzw');

// Set interleave and deinterleave options
$naps2->setInterleave('odd');
$naps2->setAltInterleave('even');
$naps2->setDeinterleave('odd');
$naps2->setAltDeinterleave('even');

// Set the reverse option to reverse the order of pages
$naps2->setReverse(true);

// Set placeholders for missing metadata
$naps2->setPlaceholders('n/a');

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

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

// Process the output as needed

Requirements

  • PHP 5.6 or above
  • NAPS2 installed and configured

  Files folder image Files (4)  
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 README.md Doc. Read me

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

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:125
This week:0
All time:9,440
This week:38Up