• 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

Google API Heatmap Layer exception, why?

VichUploaderBundle error "Expected argument of type "File", "NULL" given" when submitting the form without selecting any file

PHP: Print caught exception like Xdebug

How to Generate PDF invoice to XML format using mPDF

Laravel database insert with combining array and string

PHP Startup Unable to load dynamic library /usr/lib/php/20151012/php_mysqli.dll

Send Outlook 2010 email using PHP

Generate random username based on full name php

Failing validation doesn't stop code execution in livewire component

Invalid value in field "itemtype" in Google Search Console

"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP

Coinpayments create_transaction "ERROR: Invalid command!"

WooCommerce: Add/display Product or Variation custom field everywhere

Show only featured products in Woocommerce shop page

Return new collection without modifying original collection

About Contact Privacy policy Terms and conditions