1. Go to this page and download the library: Download ptsilva/document-counter library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ptsilva / document-counter example snippets
$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
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
}
}