kuasarx / php-scan
PHP类,用于与NAPS2(Not Another PDF Scanner 2)控制台功能交互
dev-main
2023-10-09 21:06 UTC
This package is auto-updated.
Last update: 2024-09-09 23:25:13 UTC
README
php-scan是一个PHP类,它提供了一个方便的包装,用于与NAPS2(Not Another PDF Scanner 2)控制台功能交互。
附加信息: 命令行使用
2023年8月PHP类创新奖获得者
目录
特性
- NAPS2控制台功能的简化PHP包装。
- 设置扫描文档的输出文件路径和格式。
- 指定电子邮件选项以将扫描件作为附件发送。
- 导入一个或多个PDF/图像文件以包含在输出中。
- 将多个文件合并为单个输出文件。
- 在不同的格式之间转换文件。
- 设置收件人、主题和正文以发送电子邮件。
- 启用或禁用PDF生成时的OCR(光学字符识别)。
- 设置扫描配置文件和详细程度。
- 控制要执行的扫描数量和每次扫描之间的延迟。
- 强制覆盖现有文件。
- 切片并选择要扫描的特定页面。
- 设置PDF元数据选项,例如标题、作者、主题和关键词。
- 调整图像转换的JPEG质量。
- 指定TIFF压缩选项。
- 控制扫描的交织和解交织选项。
- 反转输出中页面的顺序。
- 设置缺失元数据的占位符。
- 与PHP 5.6或更高版本以及NAPS2安装兼容。
安装
使用Composer安装此包
composer require kuasarx/php-scan
使用
<?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
要求
- PHP 5.6或更高
- NAPS2已安装并配置
