• 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

How to properly set "0000-00-00 00:00:00" as a DateTime in PHP

How to fix this error : Ask your hosting provider to use PHP 7.2.5 or higher for both HTTP and CLI?

How to keep value of selected value after form submission?

Invalid value in field "itemtype" in Google Search Console

Maatwebsite Excel 3.1 : how do I skip duplicate data when imported?

HTML + PHP + PHPMAILER

get data-value with variable value

How to set time with DateTime modify?

Confirm Leave on External Links in Wordpress

Appending data to an anchor tag

"There is no active transaction" when refreshing database in Laravel 8.0 test

PHP error: "The zip extension and unzip command are both missing, skipping."

Laravel s3 upload file with metadata using pre-signed url

Don't show recurring price for WooCommerce subscriptions worth 0$

Put content of wordpress page inside div

About Contact Privacy policy Terms and conditions