Search code examples
phppdfhtml2pdf

How to attach logo to pdf file and send to mail


My question is about to how to show the logo at the generated pdf file and send it to mail? I am using html2pdf class to generate my pdf and I am getting pdf file to my mail but when I am using img tag it gets an error. How to use image tag?

<?php
$content .= '<td>Jersey Size :  ' . $result->r_jerseysize . '</td> </tr>';
$content .= '<tr>
              <td style="padding:0 80px 0 -15px;"><img src="https://www.example.com/certificates/cert.jpg"></td>
            </tr>';
$content .= '<tr>
               <td style="padding:10px 0 14px 0;">Full Name: ' .$name. '</td>
            </tr>';
?>

Solution

  • If you host the image on your server you can use something like that :

    <?php
    $content .= '<td>Jersey Size :  ' . $result->r_jerseysize . '</td> </tr>';
    $content .= '<tr>
                  <td style="padding:0 80px 0 -15px;"><img src="certificates/cert.jpg"></td>
                </tr>';
    $content .= '<tr>
                   <td style="padding:10px 0 14px 0;">Full Name: ' .$name. '</td>
                </tr>';
    ?>
    

    With the path from your index.php => 'certificates/cert.jpg'