public function getPdf($item, $sendMail = false)
 {
     $downloadPdf = $sendMail ? true : false;
     /* @var Subscriber $item */
     $twigContent = $this->render('@Ticket/Subscriber/pdf.html.twig', array('subscriber' => $item));
     $content = $twigContent->getContent();
     require_once 'html2pdf/html2pdfController.php';
     require_once 'pjmail/pjmail.class.php';
     $html2pdf = new \html2pdf('P', 'A4', 'nl');
     $html2pdf->WriteHTML($content);
     $content_pdf = $html2pdf->Output('Ticket-20935.pdf', $downloadPdf);
     if ($sendMail) {
         $mail = new \PJmail();
         $mail->setAllFrom('*****@*****.**', "Reindert Vetter");
         $mail->addrecipient('*****@*****.**');
         $mail->addsubject('Dit is een test');
         $mail->text = 'In de bijlage kan je de ticket vinden';
         $mail->addbinattachement('test.pdf', $content_pdf);
         $mail->sendmail();
     } else {
         echo $content_pdf;
         exit;
     }
 }
Ejemplo n.º 2
0
<div style="position: absolute;bottom: 50px;text-align: left;line-height: 22px;">
  358. Lot Sidi Ghanem Industriel -MARRAKECH-mail:autotroisbservices@gmail.com<br>
  GSM :06 61 23 38 27 /Tel/Fax: 05 24 33  54 54/ site web : www.auto3bservices.com<br>
  RC N° 68863-PATENTE N° 46296302- I.F N° 15258590- C.N.S.S N° 4463684
</div>
<div style="position: absolute;bottom: 30px;right:0;">
<img src="images/qrcode.jpg" width="100">
</div>

<?php 
$content = ob_get_clean();
require_once dirname(__FILE__) . '/vendor/autoload.php';
try {
    $html2pdf = new HTML2PDF('P', 'A4', 'fr');
    //      $html2pdf->setModeDebug();
    $html2pdf->setDefaultFont('Arial');
    $html2pdf->writeHTML($content, isset($_GET['vuehtml']));
    //$html2pdf->Output('facture.pdf');
    $content_PDF = $html2pdf->Output('', true);
    require_once dirname(__FILE__) . '/pjmail/pjmail.class.php';
    $mail = new PJmail();
    $mail->setAllFrom('webmaster@mon_site.net', "Mon site perso");
    $mail->addrecipient('*****@*****.**');
    $mail->addsubject("Exemple envoie de PDF");
    $mail->text = "Ceci est un exemple d'envoie de fichier PDF";
    $mail->addbinattachement("mon_document.pdf", $content_PDF);
    $res = $mail->sendmail();
} catch (HTML2PDF_exception $e) {
    echo $e;
    exit;
}