• 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

How to get rid of ampersand using WP Nonce URL and WP Redirect or PHP header

Display Brand Name Above Product Title in Woocommerce Cart, Checkout Page, Orders and Email Notification

Elasticsearch - Want to sort by field in all indices where that particular field available or not if not then avoid it

How to remove index.php and index from the URL using htaccess | PHP

Get WooCommerce products from specific category

Upload a file Using PHP and JavaScript

target [LaravelFortifyContractsRegisterViewResponse] is not instantiable

Symfony/Form add attribute based on the data

How to identify whether webp image is static or animated?

Filter array by skipping every nth element from the end

PHPExcel How to set conditional formatting to change cell background color based on cells values

Adding one microsecond to Datetime object in PHP

Batch request Google Calendar php API

java URL working on browser but not in client program

cakephp save drag and drop list order to database

About Contact Privacy policy Terms and conditions