http://www.verypdf.com/  Home  PDFTools  Document  Support  Articles  Products  Downloads

PDF Page Numberer - Advanced PDF Tools
Change Creator, Producer, Dates, Author, Title, Subject & Keywords
Resize, rotate PDF pages, set page margin
Set open actions, compress PDF files

You can use PDF Page Numberer to get the page number from an existing PDF file, you can also call PDF Page Numberer Command Line from your script to count the page number for all PDF files in a folder.

PDF file contains a "/Count" tag, you can use following PHP code to read the "/Count" value from PDF file directly,

<?php
if (!$fp = @fopen($_REQUEST['file'],"r")) {
        echo 'failed opening file '.$_REQUEST['file'];
}
else {
        $max=0;
        while(!feof($fp)) {
                $line = fgets($fp,255);
                if (preg_match('/\/Count [0-9]+/', $line, $matches)){
                        preg_match('/[0-9]+/',$matches[0], $matches2);
                        if ($max<$matches2[0]) $max=$matches2[0];
                }
        }
        fclose($fp);
echo 'There '.($max<2?'is ':'are ').$max.' page'.($max<2?'':'s').' in '. $_REQUEST['file'].'.';
}
?>

However, a simple script will not do it completely, because some PDF files are contain nesting level of "/Count" tag, above simple PHP code can't read the nesting level of "/Count" tag correctly.

Now, you can use our PDF Page Numberer Command Line to read the page count from PDF file, for example,

pdftools.exe -r -i test.pdf

In general, above command line will output following information,

PDF FileName : D:\temp4\test.pdf
PDF Version : 1.4
PDF Security : 0
PDF PageCount : 1
MediaBox :
page 0 MediaBox:[0 0 595 841]
CropBox :
OpenAction : Magnification: Default
Title :
Keywords :
Subject :
Creator : VeryPDF Free Text To PDF Converter v1.5
Author :
CreatedDate : D:20110520104245-08'00'
Producer : VeryPDF.com Inc (http://www.verypdf.com)
ModifyDate : D:20110520104245-08'00'
SavedBy :
Rotate :
PageMode :
ViewReference :
PageLayout :
MetaData :

This is trial version, please go to www.verypdf.com to purchase the full version, thank you.

File Pages Count: 1.

---------------------------------------------------------------------------------------------------

As you see, the last line is the "File Pages Count:", you can use PDF Page Numberer Command Line to count the number of pages in PDF file easily.

In the PDF Page Numberer GUI application, you can click right button on a PDF file,

Show Files Info in PDF Page Numberer software

Select "Show Files Info" menu item, you will see the detailed information for this PDF file,

Detailed information of "Show Files Info"

Click here to learn more...


Home | Products | Downloads | Support | Links | Contact

Copyright © 2000- VeryPDF.com, Inc. All rights reserved.
Send comments about this site to the webmaster.