简体   繁体   中英

imagick binary to count number of pages in a pdf file

Could someone suggest the php code using exec() function to execute a binary of imagick to count the pages in a pdf file. Any suggestions would be great. Thanks!

Regards Rahul

Please keep in mind that ImageMagick uses ghostscript to slurp pdf files, so this may be a grossly inefficient way to simply count pages.

What I do is use pdftk to burst the pages, then count the number of output files. But it happens that I also want to process the output files.

You can also use pdftk's data dump to count the pages.

This command line works nicely on *nix.

pdftk myfile.pdf dump_data | grep NumberOfPages | cut -d " " -f 2

使用ImageMagick随附的标识:

$pages = exec("/usr/bin/identify -format %n <filename>");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM