user3789344
user3789344

Reputation: 81

how to get total number of pages using pdftk?

i am using pdftk to get total page number of a pdf file in php. I am using the code. my pdftk.exe file is in

assets/pdftk folder and my pdf file is in Files folder

$command = '../assets/pdftk/pdftk.exe ';
$command.="../Files/" . $fileNames;
$command.="dump_data | grep NumberOfPages";
exec($command);

i need to get number of pages in a string.how to do this.thanks in advance

Upvotes: 3

Views: 4714

Answers (1)

VeYroN
VeYroN

Reputation: 760

This works for me:

$pageCount = intval('pdftk path/to/pdf.pdf dump_data | grep "NumberOfPages" | cut -d":" -f2');

Upvotes: 6

Related Questions