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

查看:29
本文介绍了仅使用 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天全站免登陆