• 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

PHP Array split string and Integers

Laravel Gates using model and returns "Using $this when not in object context" Line 28 of AzureUser model

Telegram bot doesn't answer

yii2 and mssql insert varbinary into model

Warning: sqlite_query() expects parameter 1 to be resource, string given

Need to display only array value in JSON output

How can I solve "laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system"?

"cannot list resources" error from WooCommerce REST API

Execute only one time and then wait set period of time before executing again

WordPress + Nginx on non-standard port behind AWS ELB results in broken links

Getting error: CodeIgniterDatabaseBaseResult::getResult in CodeIgniter

SMTP "Error: DATA not accepted from server!" Opencart 2.3 on InMotionHosting

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

WHM Enabling mod_rewrite

Handling expired token in Laravel

About Contact Privacy policy Terms and conditions