• 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

Add a text next to stock quantity if it is less than 10 in Woocommerce single product

Show only featured products in Woocommerce shop page

Twig - How to check if variable is a number / integer

Put content of wordpress page inside div

Check if my GET request has Header: Token

Create tags in laravel post publishing

How to make Canonicals with PHP

how to fix Service provider class not found when using repository?

How to add a custom field to all Woocommerce attribute terms using add_action

How to load Codeigniter 4 lang file into an array variable

phpseclib 2.0 can not use Composer to create autoload

echo language construct is discouraged. (PHP)

Input and output values for php into the browser?

Edit product hook WooCommerce

Component install error: JInstaller: :Install: File does not exist

About Contact Privacy policy Terms and conditions