I\'m trying to read metadata attached to arbitrary PDFs: title, author, subject, and keywords.
Is there a PHP library, preferably open-source, that can read PDF meta
You may use PDFtk to extract the page count:
// Windows
$bin = realpath('C:\\pdftk\\bin\\pdftk.exe');
$cmd = "cmd /c {$bin} {$path} dump_data | grep NumberOfPages | sed 's/[^0-9]*//'";
// Unix
$cmd = "pdftk {$path} dump_data | grep NumberOfPages | sed 's/[^0-9]*
If ImageMagick is available you may also use:
$cmd = "identify -format %n {$path}";
Execute in PHP via shell_exec():
$res = shell_exec($cmd);