New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

ptsilva/document-counter

A simple document page counter. Works with laravel and out of the box
28 2
Install
composer require ptsilva/document-counter
Latest Version:v0.0.29
License:MIT
Last Updated:Nov 4, 2016
Links: GitHub  ·  Packagist
Maintainer: ptsilva

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

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

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
    }

}

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

648,266,899 9,701
laravel/framework

The Laravel Framework.

604,216,237 34,982
laravel/tinker

Powerful REPL for the Laravel framework.

512,508,631 7,443
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

429,221,767 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

407,699,310 4,663

Version History

Version Released License
v0.0.29 MIT
v0.0.23 MIT
Pre-releases (1)
Version Released License
v0.2.33-RC1 MIT