note 79266 added to ref.pdf

From: Date: Sun, 18 Nov 2007 20:25:47 +0000
Subject: note 79266 added to ref.pdf
Groups: php.notes 
Request: Send a blank email to php-notes+get-132385@lists.php.net to get a copy of this message
To extend alex's example earlier, you can use a couple of switches inside the pdf doc to give you the total number of pages, without using any ext. I would have added the whole code, however the site keeps on saying "line is too long... yadayada". Open the doc using fopen("$file", "rb"); (for reading) Test the first approx 1000b for the following regex <?php if(preg_match("/\/N\s+([0-9]+)/", $contents, $found)) { return $found[1]; } ?> If that doesn't return anything, you have to read the rest of the file: <?php preg_match_all("/\/Type\s*\/Pages\s*\/Kids\s+ \[.*?\]\s*\/Count\s+([0-9]+)/"); ?> This may return more than one, so look through for the highest value, which is the total number of pages in your doc. ---- Server IP: 194.145.210.3 Probable Submitter: 82.25.99.44 ---- Manual Page -- http://www.php.net/manual/en/ref.pdf.php Edit -- https://master.php.net/note/edit/79266 Del: integrated -- https://master.php.net/note/delete/79266/integrated Del: useless -- https://master.php.net/note/delete/79266/useless Del: bad code -- https://master.php.net/note/delete/79266/bad+code Del: spam -- https://master.php.net/note/delete/79266/spam Del: non-english -- https://master.php.net/note/delete/79266/non-english Del: in docs -- https://master.php.net/note/delete/79266/in+docs Del: other reasons-- https://master.php.net/note/delete/79266 Reject -- https://master.php.net/note/reject/79266 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#132385) next »