PHPackages                             dhina-technologies/pdf-scanner-with-keys - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. dhina-technologies/pdf-scanner-with-keys

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

dhina-technologies/pdf-scanner-with-keys
========================================

Extract keys from Digital PDFs

v1.0.4(4mo ago)03MITBladePHP ^8.1

Since Jan 6Pushed 4mo agoCompare

[ Source](https://github.com/v-IJU/pdf-scanner-with-keys)[ Packagist](https://packagist.org/packages/dhina-technologies/pdf-scanner-with-keys)[ RSS](/packages/dhina-technologies-pdf-scanner-with-keys/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (6)Used By (0)

PDF Scanner with Custom Keys
============================

[](#pdf-scanner-with-custom-keys)

[![Latest Version on Packagist](https://camo.githubusercontent.com/57306853dbedeb821f56806e7a2633893f2402d56bbfeaf3b91050d99d8089e9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6468696e612d746563686e6f6c6f676965732f7064662d7363616e6e65722d776974682d6b6579732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dhina-technologies/pdf-scanner-with-keys)[![Total Downloads](https://camo.githubusercontent.com/95250a7850827352085f71049a68c1e29d9d425203dcee995594c4cc357533cc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6468696e612d746563686e6f6c6f676965732f7064662d7363616e6e65722d776974682d6b6579732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dhina-technologies/pdf-scanner-with-keys)

A powerful Laravel package to extract data from complex PDFs such as **ITR Form 16**, **Bank Statements**, and **Invoices** using **custom keywords** and **multi-line detection logic**.

---

📋 Prerequisites
---------------

[](#-prerequisites)

This package uses the **`pdftotext`** binary. You **must install it**  on your system before using this package.

```
composer require spatie/pdf-to-text

```

---

### 🪟 Windows

[](#-windows)

1. Download **Xpdf command-line tools** from:
2. Extract the ZIP file.
3. Locate `pdftotext.exe`

Example path:

```
C:\xpdf\bin64\pdftotext.exe

```

---

### 🐧 Linux (Ubuntu / Debian)

[](#-linux-ubuntu--debian)

```
sudo apt-get update
sudo apt-get install poppler-utils

```

---

### 🍎 macOS

[](#-macos)

Using Homebrew:

```
brew install poppler

```

---

🚀 Installation
--------------

[](#-installation)

Install the package via Composer:

```
composer require dhina-technologies/pdf-scanner-with-keys

```

Publish the configuration file and test assets:

```
php artisan vendor:publish --tag="pdf-scanner-assets"

```

---

⚙️ Configuration
----------------

[](#️-configuration)

Set the path to the `pdftotext` binary in your `.env` file.

### Windows

[](#windows)

```
PDF_SCANNER_BINARY="C:\xpdf\bin64\pdftotext.exe"

```

### Linux / macOS

[](#linux--macos)

```
PDF_SCANNER_BINARY="/usr/bin/pdftotext"

```

---

🛠️ Usage
--------

[](#️-usage)

### 1️⃣ Built-in Test Page (UI)

[](#1️⃣-built-in-test-page-ui)

This package includes a built-in **visual test page** to verify PDF scanning.

Start the Laravel server:

```
php artisan serve

```

Open in browser:

```
http://localhost:8000/test-package

```

Supports:

File upload

Tag‑based field selection

Preset selection

JSON output view

Upload a PDF and enter comma-separated keys.

Example:

```
PAN, TAN, Assessment Year or Select Preset

```

---

### 2️⃣ Manual Function Call

[](#2️⃣-manual-function-call)

You can use the scanner programmatically in controllers or services.

```
use Dtech\PdfScanner\PdfScanner;
use Dtech\PdfScanner\PresetResolver;

$filePath = storage_path('app/pdfs/itr_form.pdf');

//what are the keys you need to extract from UI here preset also come and if you need some Random Key output you can mention here
$keys = $request->custom_keys ? $request->custom_keys : [];

$keys = PresetResolver::resolve($keys);

$result = PdfScanner::extractJson($filePath, $keys);

print_r($result['data']);

echo $result['raw_text'];
```

---

🔍 How It Works
--------------

[](#-how-it-works)

The scanner uses **Multi-Line Detection Logic**:

- Searches for configured keywords
- If the value is not found on the same line
- Automatically scans subsequent lines
- Extracts correct values even from table-style PDFs

Ideal for:

- Government forms (Form 16, ITR)
- Bank statements
- Grid-based invoices

---

📦 Output Format
---------------

[](#-output-format)

```
[
    'data' => [
        'pan_number' => 'ABCDE1234F',
        'assessment_year' => '2023-24',
        'employer' => 'XYZ Private Limited'
    ],
    'raw_text' => 'Full extracted PDF text...'
]
```

🧩 Rule System (Core Feature)
----------------------------

[](#-rule-system-core-feature)

Each field uses a Rule Class.

Rule Interface

```
