• 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

Batch request Google Calendar php API

Woocommerce Edit Message "An account is already registered with your email address. Please log in."

Load a .env file with PHP

Laravel 5 issue with wherePivot

Laravel: Why is my variable not being set while it's in the construct function of the controller?

javascript html popup window

Magento Installation SQLSTATE[HY000] [2002] No such file or directory error

Symfony 4: "Autowire: you should configure its value explicitly."

Prestashop cUrl Login

Additional price based on cart item count in WooCommerce

Dynamic table in HTML using MySQL and php

Update Total in checkout of Woocommerce with Ajax Request

How to change HTML structure inside WP <head>

Last order would be re-order in wooCommerce. How is it possible?

browsersync doesn't work with XAMPP

About Contact Privacy policy Terms and conditions