• 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

Laravel database insert with combining array and string

Populate Dynamic Dropdowns List in Codeigniter

Failing validation doesn't stop code execution in livewire component

How do I get friend list from Friends table with counts of friends of my friends

GuzzleHttp Hangs When Using Localhost

Laravel 5.5 change unauthenticated login redirect url

WHERE IN array binding in DB::raw laravel 5.4

Yii2 redirecting to previous page after login

How to install ZeroMQ for PHP on an Alpine Linux container?

PHP array, move keys and values to new array, but mix it up

VichUploaderBundle error "Expected argument of type "File", "NULL" given" when submitting the form without selecting any file

str_replace or preg_replace random number from string

Spam Filter in Contact Form

I want to use codeigniter foreign character library in my custom PHP project how i can use it?

laravel sanctum Route [login] not defined

About Contact Privacy policy Terms and conditions