仅使用PHP计算PDF中的页面数 [英] Count the number of pages in a PDF in only PHP

查看:58
本文介绍了仅使用PHP计算PDF中的页面数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种方法来计算PHP中PDF的页数.我做了一些谷歌搜索,发现的唯一东西都是利用shell/bash脚本,perl或其他语言,但是我需要使用本机PHP.是否有任何库或如何执行此操作的示例?

解决方案

您可以使用PHP的ImageMagick扩展名. ImageMagick理解PDF格式,您可以使用identify命令提取页面数. PHP函数为 Imagick :: identifyImage().

I need a way to count the number of pages of a PDF in PHP. I've done a bit of Googling and the only things I've found either utilize shell/bash scripts, perl, or other languages, but I need something in native PHP. Are there any libraries or examples of how to do this?

解决方案

You can use the ImageMagick extension for PHP. ImageMagick understands PDF's, and you can use the identify command to extract the number of pages. The PHP function is Imagick::identifyImage().

这篇关于仅使用PHP计算PDF中的页面数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆