开发者

How to merge multiple single-page TIFFs into a PDF with PHP?

开发者 https://www.devze.com 2023-02-22 17:50 出处:网络
I have a massive number of TIFF images which are single scanned pages. They are each a page of multi-page do开发者_Python百科cuments.

I have a massive number of TIFF images which are single scanned pages. They are each a page of multi-page do开发者_Python百科cuments.

I need to be able to deliver this multi-page document to my users as a PDF. Nothing special is required except combining the images into one document, in the right order.

The images locations are provided via the result of a MySQL query in PHP as an array, i.e:

c:\images\04\DUDDSDFF.tif,c:\images\04\EDFRTOFN.tif,c:\images\04\EFSDOSDG.tif

The current dev environment I am working in uses XAMPP running on Win Server 2K3.

Any suggestions/solutions would be most appreciated.

Cheers


I have done done something similar before where I used the Imagick() class to convert form TIFF to PNG and then used TCPDF to generate the PDF.


$pdfThumb = new \Imagick();
foreach ($tiffPics as $tiffPic) {
    $pdfThumb->addImage($new \Imagick($tiffPic));
}
$pdfThumb->writeImages($absolutePdfName, true);


The answer from @chariothy is close but doesn't actually work. I just had a need to combine multiple tif files into a single pdf file and this is my solution, tested and working.

$pdf = new \Imagick();

foreach ($tif_file_paths as $file_path){

    $pdf->addImage(new \Imagick($file_path));
}

$pdf->writeImages('path/to/save/file/test-combined.pdf', true);
0

精彩评论

暂无评论...
验证码 换一张
取 消