简体   繁体   English

imagick二进制文件可计算pdf文件中的页数

[英]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. 有人可以建议使用exec()函数的php代码执行imagick的二进制文件来计算pdf文件中的页数。 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. 请记住,ImageMagick使用ghostscript吞噬pdf文件,因此这可能是仅计算页面数的非常低效的方法。

What I do is use pdftk to burst the pages, then count the number of output files. 我要做的是使用pdftk爆裂页面,然后计算输出文件的数量。 But it happens that I also want to process the output files. 但是碰巧我也想处理输出文件。

You can also use pdftk's data dump to count the pages. 您还可以使用pdftk的数据转储来计数页面。

This command line works nicely on *nix. 该命令行在* nix上运行良好。

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

使用ImageMagick随附的标识:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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