且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用PHP将JPG合并为一个PDF

更新时间:2023-02-12 21:50:02

PHP 中,您可以使用:

$images = array("file1.jpg", "file2.jpg");

$pdf = new Imagick($images);
$pdf->setImageFormat('pdf');
$pdf->writeImages('combined.pdf', true); 

true 参数c> writeImages 很重要,因为它会使方法编写一系列图像,而不仅仅是一个。



您也可以从命令行执行此操作:

The true parameter on writeImages is important because it will make the method write a sequence of images, not only one.


You also can do this from command line:
convert file1.jpg file2.jpg output.pdf