Insert image in pdf in php using mpdf

69

Here,below is my code for converting an image into pdf using mpdf. $html containsupload/tulips.jpg But,when the function executes the pdf file created and an image icon shows there with the locationupload/tulips.pdf. Kindly tell me why this is happening because no bug is coming.

   private function ConvertImageToPdf($inputPath,$outputPath)
            { 
                $mpdf=new mPDF();
                $html='<img src='.$inputPath.'/>';
                $mpdf->WriteHTML($html);
                $mpdf->Output($outputPath.".pdf",'F');
                $mpdf->debug = true;

            }
844

Answer

Solution:

$html='<img src="'.$inputPath.'"/>';

eg"" around image-path, and you should be good (if the image exists)

In the mPDF-package/examples there is aexample04_images.php you can try out.

PS : You should set$mpdf->debug = true before$mpdf->Output()

347

Answer

Solution:

its the comma problem

$html='<img src="'.$inputPath.'"/>';

People are also looking for solutions to the problem: php - MySQLi multi_query won't work

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.