• 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 do I refresh a DIV content?

Statement that checks whether a URL contains a particular path?

Laravel UUID generation

phpmyadmin : Depends: php-twig (>= 2.9) but 2.6.2-2 is to be installed. WHAT?

Yii2 redirecting to previous page after login

Failing validation doesn't stop code execution in livewire component

Stop caching for PHP 5.5.3 in MAMP

Laravel views are showing from cache on one server but works fine on other server

Facebook PHP SDK - will not logout properly

Assets not referencing to public folder (Laravel)

how to retrieve the first and last instance of a row in pdo dataset

Laravel no logout option from menu after successfull login

How to modify CSS in a specific page of the WP admin dashboard (backend)

I want to store data in new index as per my key in php [duplicate]

PHP Form Not Inserting

About Contact Privacy policy Terms and conditions