2017 © Pedro Peláez
 

library document-counter

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

image

ptsilva/document-counter

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

  • Sunday, October 30, 2016
  • by ptsilva
  • Repository
  • 1 Watchers
  • 1 Stars
  • 17 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

PDF Counter Pages

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

Instalation

 composer require ptsilva/pdf-counter-pages

Need install GhostScript also, (*1)

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

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

Ptsilva\DocumentCounter\Providers\DocumentCounterServiceProvider::class,

Copy the package config to your local config with the publish command:, (*3)

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

Just use, (*4)

$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, (*5)

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
    }

}

The Versions

30/10 2016

0.2.0.0-dev

0.2.0.0-dev

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

  Sources   Download

MIT

The Requires

 

30/10 2016

0.2.0.x-dev

0.2.0.9999999-dev

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

  Sources   Download

MIT

The Requires

 

30/10 2016

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

 

30/10 2016

dev-v0.1.33-dev

dev-v0.1.33-dev

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

  Sources   Download

MIT

The Requires

 

30/10 2016

v0.0.23

0.0.23.0

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

  Sources   Download

MIT

The Requires

 

30/10 2016

v0.0.29

0.0.29.0

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

  Sources   Download

MIT

The Requires

 

30/10 2016

v0.2.33-RC1

0.2.33.0-RC1

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

  Sources   Download

MIT

The Requires

 

30/10 2016

0.1.0.x-dev

0.1.0.9999999-dev

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

  Sources   Download

MIT

The Requires