• 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

XDebug not working in VScode for php debugging

wordpress function breaks wp-admin

Laravel Factory not calling callback 'afterCreating'

Need to display only array value in JSON output

Magento 2 - Controller returning blank page

Set quantity minimum, maximum and step at product level in Woocommerce

Fatal error: Uncaught mysqli_sql_exception: Unknown database 'test' in ... (How do I fix that? Using PHP)

PHP: Insert marker every 3 iterations

printing all running session variable in laravel 5.1

How to use functions that are declared in snippets in Evolution CMS (Modx) in an external PHP Script?

How to change the app environment at run time?

Adding the custom page with add_menu_page function on Wordpress

how to upload binary image to sql server using php laravel

Php - Sum up the numbers in an array one by one

Cross-Origin Resource Sharing (CORS) witth Laravel and Vuejs

About Contact Privacy policy Terms and conditions