PHP计算PDF页码 使用其他库存在计算不准确和部分压缩文件不支持问题。 安装 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; 参考 Get the number of pages in a PDF document Simple PHP wrapper to the pdfinfo unix tool