How to convert images to pdf using PHP? [closed]
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question 开发者_如何转开发Can anyone have an idea how to convert images to pdf using PHP?
Any response will be appreciated.
Thanks...
If you have ImageMagick installed and exec
permissions,
exec("convert foo.jpeg foo.pdf");
if you have Ghostscript and Imagemagick install on system than you can try this :
exec("convert -geometry 1600x1600 -density 200x200 -quality 100 $pdf_path $image_path");
You may use, MPDF and Normal PHP upload function to convert image into pdf. Just follow the below steps. Create a form to upload the file field "jpgtoconvert"
<?php
$mpdf = new mPDF();
$file = $_FILES['jpgtoconvert']['tmp_name'];
$size = getimagesize ( $file );
$width = $size[0];
$height = $size[1];
$mpdf->WriteHTML('');
$mpdf->Image($file,60,50,$width,$height,'jpg','',true, true);
$mpdf->Output($filename);
?>
This function should output the pdf on the browser.
精彩评论