PHP PDF转PNG图片
super
2023-01-09 21:39
1686
1)安装 PHP Imagick 拓展
2)安装 ghostscript
https://rongsp.com/article/310.html
composer require spatie/pdf-to-image
4)转换
$pathToPdf = './test.pdf';
$pdf = new \Spatie\PdfToImage\Pdf($pathToPdf);
$total = $pdf->getNumberOfPages();
for ($i = 1; $i <= $total; $i++ ) {
$pdf->setOutputFormat('png')
->setPage($i)
->saveImage('./' . $i . '.png');
}
0 条讨论