Search by

portpro / document-reader

ibrahim-portprosa

Self-hosted text, table and labeled-field extraction for documents and images.

Package info

github.com/portpro-sa/document-reader

pkg:composer/portpro/document-reader

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-11-26 22:02 UTC

This package is not auto-updated.

Last update: 2026-11-26 22:07:55 UTC


README

Extract text, labeled fields and tables from documents and images, then export the result as JSON. The package runs on your own server with PHP 8.2 or later. It works in Laravel, in standalone PHP applications and from the command line. Reading a document requires no API key and incurs no per-page service fee.

Install with Composer

Run these commands in your application directory to install the tagged release directly from GitHub.

composer config repositories.portpro-document-reader vcs https://github.com/portpro-sa/document-reader
composer require "portpro/document-reader:^0.1"

Composer checks the required PHP extensions. To process PDFs and images, install Poppler and Tesseract on the machine where PHP runs. On Ubuntu or Debian:

sudo apt-get install poppler-utils tesseract-ocr tesseract-ocr-eng tesseract-ocr-ara tesseract-ocr-chi-sim

On macOS with Homebrew:

brew install poppler tesseract tesseract-lang

Read a document

vendor/bin/read-document inspection.pdf > inspection.json

In PHP, use the Composer autoloader and pass a local file path:

require __DIR__.'/vendor/autoload.php';

use PortPro\DocumentReader\DocumentReader;

$result = (new DocumentReader())->read(__DIR__.'/inspection.pdf');
foreach ($result['pages'] as $page) {
    echo $page['text'], PHP_EOL;
}

A line such as Inspection ID: QC-7319 produces a field with label Inspection ID and value QC-7319. The full text remains available alongside extracted fields and tables. Compare the sample document with its complete JSON output.

Supported inputs

Input What the reader extracts
PDF Embedded text from digital pages and OCR from scanned pages
JPEG, PNG, WebP, BMP Printed text using Tesseract. The default languages are English, Arabic and simplified Chinese
DOCX, XLSX, PPTX Word body text and tables, worksheet cells and PowerPoint slide text
UTF-8 TXT, CSV, TSV, JSON Text, delimited rows and cells, or the parsed JSON value
Bills of lading in supported formats Additional suggestions for the bill number, ports, cargo description, container serials and weights

The maximum input size is 10 MiB. Individual formats have additional limits. Check the extraction reference for the JSON structure, OCR behavior, format limits and errors. See the Laravel integration guide for temporary uploads and JSON responses.

Run the example from a clone

git clone https://github.com/portpro-sa/document-reader.git
cd document-reader
composer install
bin/read-document examples/inspection.txt
composer test

License

Released by PortPro under the MIT License.