Download the PHP package ikromjon/nativephp-mobile-document-scanner without Composer
On this page you can find all versions of the php package ikromjon/nativephp-mobile-document-scanner. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package nativephp-mobile-document-scanner
NativePHP Mobile Document Scanner
Scan documents with automatic edge detection, perspective correction, and cropping in your NativePHP Mobile app — powered by native platform APIs.
Quick Start
That's it. The scanner opens, the user scans, and you get the file paths back via events. See below for full options and JavaScript usage.
How It Works
| Platform | Native API | Features |
|---|---|---|
| iOS | VisionKit (VNDocumentCameraViewController) |
Auto edge detection, perspective correction, shadow removal, multi-page |
| Android | Google ML Kit Document Scanner | Auto edge detection, cropping, rotation, multi-page, gallery import |
No external API keys or internet required. Camera permission is handled automatically.
Installation
Build your app (plugin requires a native build):
Note: The scanner requires a native build on a real device — it won't work with
php artisan serve. If you callscan()without a native build, you'll see a warning in your Laravel log.
Configuration
Optionally publish the config file:
| Key | Default | Description |
|---|---|---|
default_max_pages |
0 |
Default max pages per scan (0 = unlimited) |
max_pages_limit |
100 |
Absolute cap on pages per scan |
default_output_format |
jpeg |
Default output format (jpeg or pdf) |
default_jpeg_quality |
90 |
Default JPEG compression quality (1-100) |
storage_directory |
scanned-documents |
Subdirectory for scanned files |
default_gallery_import |
false |
Allow gallery import (Android only) |
default_scanner_mode |
full |
Scanner mode: base, filter, full (Android only) |
Usage (PHP)
Scan a Document
The scan() method opens the native scanner UI and returns immediately. Results are delivered asynchronously via events.
Type-Safe DTO
Scan Parameters
| Parameter | Type | Platform | Description |
|---|---|---|---|
maxPages |
int | Both | Max pages to scan (0 = unlimited) |
outputFormat |
OutputFormat|string | Both | jpeg or pdf |
jpegQuality |
int | Both | JPEG quality 1-100 (only for jpeg output) |
galleryImport |
bool | Android only | Allow importing from device gallery |
scannerMode |
ScannerMode|string | Android only | base, filter, or full |
Full Livewire Example
A complete component that scans documents and displays the results:
Important: Use
#[OnNative(...)](not#[On(...)]) for NativePHP events.
Listening to Events (Laravel)
Usage (JavaScript)
Events
| Event | Payload | When |
|---|---|---|
DocumentScanned |
paths, pageCount, outputFormat |
Scanning completed successfully |
ScanCancelled |
— | User cancelled the scanner |
ScanFailed |
error |
An error occurred |
PdfCreated |
path |
imagesToPdf() completed |
Scanned Files
Scanned files are saved to the app's internal storage under the configured storage_directory (default: scanned-documents). File paths returned in the DocumentScanned event are absolute paths on the device.
- JPEG output: one file per page (e.g.
scan_0.jpg,scan_1.jpg) - PDF output: a single multi-page PDF file
- Files persist until the app is uninstalled or you delete them manually
Which format to use?
JPEG (default) is the better choice for most apps. You get individual files per page, which means you can show page previews, let users view/delete specific pages, and convert to PDF later on your own terms (e.g. with fpdf). You also control file size via jpegQuality.
PDF is useful when you need a single file immediately and don't need to display or manipulate individual pages. Note that the native scanner produces the PDF directly — you can't extract page previews from it without a separate library.
See Smart Docs for an example that scans as JPEG by default and converts to PDF on demand.
Required Permissions
Android: CAMERA — declared automatically via nativephp.json. ML Kit handles the scanner UI internally.
iOS: VisionKit requests camera access at runtime. Your app's Info.plist must include an NSCameraUsageDescription string — NativePHP sets a default, but you should customize it for your app store submission (e.g. "This app uses the camera to scan documents").
No API keys or internet required.
Demo App
See Smart Docs — a full NativePHP mobile app that uses this plugin for document scanning.
Documentation
- Installation — requirements, setup steps, verification
- Configuration — all config options explained
- Usage with Livewire — Livewire components and event handling
- Usage with JavaScript — Inertia Vue/React integration
- API Reference — events, DTOs, enums, validation, contracts
JPEG-to-PDF Conversion
Combine scanned JPEG pages into a single PDF on-device — no extra PHP library needed:
Works with any JPEG files, not just scanned documents.
PDF Page Thumbnails
Extract page previews from a PDF — useful when you scan as PDF but need page-level previews:
Planned Features
- File management — list, delete, and clean up scanned files via the plugin API
- Image post-processing — grayscale, contrast, rotation on scanned images
See ROADMAP.md for full details and status.
Testing
Requirements
- PHP 8.3+
- NativePHP Mobile v3+
- iOS 13+ / Android API 21+
License
MIT