• 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

Project structure for PHP

Issue with laravel eloquent model property

SendGrid: Sending an email to multiple recipients without other emails being shown on the "to" field

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

Yoast SEO (WordPress Plugin) - Get plugin generated data manually

Add a custom text for a particular product on specific email notification in Woocommerce

Respond with status code 401 on authentication failure using Laravel and Passport?

How can I get user id from session in javascript?

add " ? " in url via htaccess RewriteRule

Convert PHP array into HTML tag attributes separated by spaces

The "client_reference_id" argument is not passed

Why does array_map() with null as callback create an "array of arrays"?

php echo xml documents with header

The difference when using if statement true === something() vs something() === true [duplicate]

Not able to override collapsible.js in magento 2

About Contact Privacy policy Terms and conditions