Package Data | |
---|---|
Maintainer Username: | ptsilva |
Maintainer Contact: | 05.paulotarso@gmail.com (Paulo Silva) |
Package Create Date: | 2016-10-30 |
Package Last Update: | 2016-11-04 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-02-07 15:04:47 |
Package Statistics | |
---|---|
Total Downloads: | 27 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 2 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
composer require ptsilva/pdf-counter-pages
Need install GhostScript also
$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
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
}
}