PHPackages                             ptsilva/document-counter - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. ptsilva/document-counter

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ptsilva/document-counter
========================

A simple document page counter. Works with laravel and out of the box

v0.0.29(9y ago)228MITPHP

Since Oct 30Pushed 9y ago1 watchersCompare

[ Source](https://github.com/ptsilva/document-counter)[ Packagist](https://packagist.org/packages/ptsilva/document-counter)[ RSS](/packages/ptsilva-document-counter/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (1)Versions (8)Used By (0)

PDF Counter Pages
=================

[](#pdf-counter-pages)

This can be used to count the total pages in PDF document
---------------------------------------------------------

[](#this-can-be-used-to-count-the-total-pages-in-pdf-document)

### Instalation

[](#instalation)

```
 composer require ptsilva/pdf-counter-pages
```

Need install [GhostScript](http://ghostscript.com/%22) also

### Out of the box

[](#out-of-the-box)

```
$path = '/var/www/html/project/document.php';

$pdf = new \Ptsilva\DocumentCounter\Documents\PDFDocument($path);

$driver = new \Ptsilva\DocumentCounter\PDFGhostScriptCounter('/usr/bin/gs');

$totalPages = $driver->process($pdf);

var_dump($totalPages); // integer
```

### Using Laravel 5

[](#using-laravel-5)

After updating composer, add the ServiceProvider to the providers array in config/app.php

```
Ptsilva\DocumentCounter\Providers\DocumentCounterServiceProvider::class,
```

Copy the package config to your local config with the publish command:

```
php artisan vendor:publish --provider="Ptsilva\DocumentCounter\Providers\DocumentCounterServiceProvider"
```

Just use

```
$path = '/var/www/html/project/document.php';

$totalPages = app('document-counter')->getTotalPages(new \Ptsilva\DocumentCounter\Documents\PDFDocument($path));

dd($totalPages); // integer
```

Or using Dependency Injection

```
use Ptsilva\DocumentCounter\Factory\DocumentCounterFactory;
use Ptsilva\DocumentCounter\Documents\PDFDocument;
class Controller
{
    public function index(DocumentCounterFactory $counter)
    {
        $path = '/var/www/html/project/document.php';

        $totalPages = $counter->getTotalPages(new PDFDocument($path));

        dd($totalPages); // integer
    }

}
```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

6

Last Release

3523d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7844797?v=4)[Paulo Silva](/maintainers/ptsilva)[@ptsilva](https://github.com/ptsilva)

---

Top Contributors

[![ptsilva](https://avatars.githubusercontent.com/u/7844797?v=4)](https://github.com/ptsilva "ptsilva (7 commits)")

### Embed Badge

![Health badge](/badges/ptsilva-document-counter/health.svg)

```
[![Health](https://phpackages.com/badges/ptsilva-document-counter/health.svg)](https://phpackages.com/packages/ptsilva-document-counter)
```

###  Alternatives

[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k245.4M23.9k](/packages/friendsofphp-php-cs-fixer)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

749284.3k35](/packages/civicrm-civicrm-core)[spatie/laravel-export

Create a static site bundle from a Laravel app

672139.5k6](/packages/spatie-laravel-export)[illuminate/process

The Illuminate Process package.

44813.9k96](/packages/illuminate-process)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
