• 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

WordPress Subquery returns more than 1 row on SELECT

PHP: How to quickly split a key=value file into associative array

Undefined Array Key error when uploading image on php

Remove product downloads section in woocommerce email notifications

Laravel eloquent update record without loading from database

Losing session data after POST from third party website

Create a new line whenever an array value reaches more than 10 characters

PHP: Print caught exception like Xdebug

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

How to insert Google Adsense Code in PHP script?

Redis Command To Sort Keys

Saving Data from form to database using AngularJS and php

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

CONCAT columns with Laravel 5 eloquent

Having trouble with PDO queries (Notice: Undefined index)

About Contact Privacy policy Terms and conditions