• 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 print last executed SQL query with Query log

How to trim a video by 4 fragments to 4 seconds using the PHP-FFMpeg?

In PHP, which is faster: preg_split or explode?

How to insert Google Adsense Code in PHP script?

Laravel Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) on a sub query with "ROW_NUMBER() OVER PARTITION"

Get latest Tweets - What API

I need to link Google Sheet with my Laravel

CodeIgniter 3 is generating a session file on each request, why?

Google API Heatmap Layer exception, why?

Alert message after submitting form in PHP

Laravel : How to Create Dropdown to Select FOREIGN KEY from Other Table?

How do I do HTTP basic authentication using Guzzle?

How to redirect to another page after n seconds in wordpress without using javascript?

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

generating a random code in php?

About Contact Privacy policy Terms and conditions