使用其他库存在计算不准确和部分压缩文件不支持问题。
安装 pdfinfo
sudo apt install poppler-utils # ubuntu debian
sudo dnf install poppler-utils # centos
安装PHP类
composer require "howtomakeaturn/pdfinfo"
计算代码
$pdf = new PDFInfo('path/to/the/pdf');
echo $pdf->pages;
Copy
参考
-
[Get the number of pages in a PDF document](https://stackoverflow.com/questions/14644353/get-the-number-of-pages-in-a-pdf-document)
-
[Simple PHP wrapper to the pdfinfo unix tool](https://github.com/howtomakeaturn/pdfinfo)