• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

How to get total pages of PDF with FPDF?

phpfpdf


PHP Snippet 1:

$pdf = new FPDF();
$pdf->AddPage();
$pdf->AddPage();
$nb = $pdf->PageNo();
$pdf->Output();

PHP Snippet 2:

    // Get the file into path 
    $path = 'LargePDF.pdf';
    // Call a the function FunctionCountPages 
    $totalPageCount=  FunctionCountPages($path);;
    echo $totalPages;
    function FunctionCountPages($path) 
          {
              $pdftextfile = file_get_contents($path);
              $pagenumber = preg_match_all("/\/Page\W/", $pdftextfile, $dummy);
              return $pagenumber;
            }
//I hope this work for you

Related Snippets

Which is faster php date functions or carbon?

PHP Include for HTML?

Popup Window and PHP form

How to put php code inside opening and closing shortcodes

Respond with status code 401 on authentication failure using Laravel and Passport?

Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, null given in

How to programmatically find public properties of a class from inside one of it's methods

how to hide previous markers when new markers added in google map javascript api

How to prevent phpmailer sending embedded image as an attachment on Gmail?

printing all running session variable in laravel 5.1

how to redirect the user back to desired URL after login page in PHP?

Additional price based on cart item count in WooCommerce

array_map triple dimensional array [duplicate]

PHP: Print caught exception like Xdebug

CodeIgniter 3 is generating a session file on each request, why?

About Contact Privacy policy Terms and conditions