• 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

Remove "estimated for {country}" text after tax amount in Woocommerce checkout page

Python - Include another Python script

Check if my GET request has Header: Token

Read users and passwords from a txt file

Mysqli multi query error

Doctrine 2 mapping referencing unique key

WAMP/Wordpress - cURL error 28: Operation timed out after 10001 milliseconds with 0 bytes received

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

Laravel Sanctum CSRF not authenticating

How to override header set in Apache config with more specific header in a virtual host

Cannot connect to own websocket server when on secured domain

best way to store error messages in Laravel (session or variable)

advanced custom fields wordpress custom class

How to map the two arrays with a duplicate value?

printing all running session variable in laravel 5.1

About Contact Privacy policy Terms and conditions