Ver Mensaje Individual
  #2 (permalink)  
Antiguo 30/05/2015, 17:16
jhonjaider1000
 
Fecha de Ingreso: abril-2015
Ubicación: Bogotá D.C - Colombia
Mensajes: 106
Antigüedad: 9 años
Puntos: 11
Respuesta: Contar páginas de un PDF?

Por si alguien en el futuro desea saber como hacerlo, es algo sencillo:
Código PHP:
function getNumPagesInPDF($filePath) {
    if (!
file_exists($filePath))
        return 
0;
    if (!
$fp = @fopen($filePath"r"))
        return 
0;
    
$i 0;
    
$type "/Contents";
    while (!
feof($fp)) {
        
$line fgets($fp255);
        
$x explode($type$line);
        if (
count($x) > 1) {
            
$i++;
        }
    }
    
fclose($fp);
    return (int) 
$i;

En internet se encuentra un script que supuestamente lo hace, pero observé una falla y es que al parecer solo sirve con ciertas versiones de pdf...

Última edición por jhonjaider1000; 29/07/2015 a las 09:26