1

Hello,
I'm using html2pdf to generate a pdf and attach to an email using the following code.
The email makes it to my inbox with an attached pdf but the pdf is always blank


<body>
<?php
// once the customer submits his/her information, he/she will receive a thank
// you message attach with a pdf file.
////////////////////////////////////////
// get the HTML
ob_start();
include('examples/res/exemple00.php');
$content = ob_get_clean();

// convert in PDF
require_once('html2pdf.class.php');
try
{
$html2pdf = new HTML2PDF('P', 'A4', 'fr');
// $html2pdf->setModeDebug();
$html2pdf->setDefaultFont('Arial');
$html2pdf->writeHTML($content, isset($_GET['vuehtml']));
$html2pdf->Output('exemple00.pdf',"S");
}
catch(HTML2PDF_exception $e) {
echo $e;
exit;
}





require_once('Mail/Mail.php');
require_once('Mail/mime.php');


// email address of the recipient
$to = "xxxxxxxxxxxx";

// email address of the sender
$from = "senderemail@yahoo.com";

// subject of the email
$subject = "here we go again";

// email header format complies the PEAR's Mail class
// this header includes sender's email and subject
$headers = array('From' => $from,
'Subject' => $subject);

// We will send this email as HTML format
// which is well presented and nicer than plain text
// using the heredoc syntax
// REMEMBER: there should not be any space after PDFMAIL keyword
$htmlMessage = <<<PDFMAIL
<html>
<body bgcolor="#ffffff">
<p align="center">
Please find the pdf attached in the email.<br>
This is generated by <b style="font-size:18pt;">FPDF</b>
</p>
</body>
</html>
PDFMAIL;

// create a new instance of the Mail_Mime class
$mime = new Mail_Mime();

// set HTML content
$mime->setHtmlBody($htmlMessage);

// IMPORTANT: add pdf content as attachment
$mime->addAttachment($pdfcontent, 'application/pdf', 'exemple00.pdf', false, 'base64');

// build email message and save it in $body
$body = $mime->get();

// build header
$hdrs = $mime->headers($headers);

// create Mail instance that will be used to send email later
$mail = &Mail::factory('mail');

// Sending the email, according to the address in $to,
// the email headers in $hdrs,
// and the message body in $body.
$mail->send($to, $hdrs, $body);


?>
</body>
</html>