generating a pdf file with utf8 characters with mpdf
<p>I'm trying to create a pdf file with mpdf and send it by e-mail.
The file is written in both english and hebrew.
I've got the file to be created correctly when I open it on the browser (with <code>$mpdf-&gt;output()</code>):
<a href="http://i.stack.imgur.com/SDZ5L.png" rel="nofollow">this is how it lloks like when it works</a>
 but then when I try opening it with the pdf viewer or when I try sending it with php mailer with addStringAttachment($stringAttachment , filename.pdf) all the hebrew comes out as just a bunch of rectangles:
<a href="http://i.stack.imgur.com/p32HM.png" rel="nofollow">this is how it looks when it doesnt work</a>
this is my code:</p>

<pre><code>    &lt;?php
//$htmlResult is set to be the pdf page - written in html.

$mpdf = new mPDF('utf-8' , 'A4-P');

$mpdf-&gt;WriteHTML($htmlResult);
$fileName = "report".$formatedFromDate.'-'.$formatedToDate;
$mpdf-&gt;Output("1234.pdf" , "D");
</code></pre>

<p>when I try to send it with phpMailer:</p>

<pre><code>$stringPdf = $mpdf-&gt;Output("1234.pdf" , "S");
$body = " ";
$subject = $fileName;

FunctionPool::sendEmail($emailAddress, $body, $subject , $stringPdf ,$fileName);
</code></pre>

<p>and the function sendMail:</p>

<pre><code>public static function sendEmail ($emailAddress , $body , $subject , $stringAttachments = NULL , $fileName = NULL) {


        //SMTP needs accurate times, and the PHP time zone MUST be set
        //This should be done in your php.ini, but this is how to do it if you don't have access to that
        date_default_timezone_set('Asia/Jerusalem');
        require_once __DIR__.'/variables.php';
        require_once __DIR__.'/PHPMailerMaster/PHPMailerAutoload.php';
        require_once __DIR__.'/PHPMailerMaster/class.phpmailer.php';
        require_once __DIR__.'/PHPMailerMaster/class.phpmaileroauthgoogle.php';
        require_once __DIR__.'/settings.php';
        //Create a new PHPMailer instance
        $mail = new PHPMailer;
        //Tell PHPMailer to use SMTP
        $mail-&gt;CharSet = "utf-8";
        $mail-&gt;isSMTP();

        //Enable SMTP debugging
        // 0 = off (for production use)
        // 1 = client messages
        // 2 = client and server messages
        $mail-&gt;SMTPDebug = 2;
        if (1 != $underDevelopment) {
            $mail-&gt;SMTPDebug = 0;
        }

        //Ask for HTML-friendly debug output
        $mail-&gt;Debugoutput = 'html';

        //Set the hostname of the mail server
        //$mail-&gt;Host = 'smtp.gmail.com';

        // use
        $mail-&gt;Host = gethostbyname('smtp.gmail.com');
        // if your network does not support SMTP over IPv6
        //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
        $mail-&gt;Port = 587;
        //Set the encryption system to use - ssl (deprecated) or tls
        $mail-&gt;SMTPSecure = 'tls';
        //Whether to use SMTP authentication
        $mail-&gt;SMTPAuth = true;
        //$mail-&gt;SMTPAutoTLS = false;        
        $mail-&gt;SMTPOptions = array(
            'ssl' =&gt; array(
            'verify_peer' =&gt; false,
            'verify_peer_name' =&gt; false,
            'allow_self_signed' =&gt; true
            )
        );


        //Username to use for SMTP authentication - use full email address for gmail
        $serversEmailAddress = **************@gmail.com";
        $serversEmailPassword = "**************";
        $systemsName = "**************";

        $mail-&gt;Username = $serversEmailAddress;
        //Password to use for SMTP authentication
        $mail-&gt;Password = $serversEmailPassword;
        //Set who the message is to be sent from
        $mail-&gt;setFrom($serversEmailAddress , $systemsName);
        //Set an alternative reply-to address
        $mail-&gt;addReplyTo($serversEmailAddress, $systemsName);
        //Set who the message is to be sent to
        $mail-&gt;addAddress($emailAddress);
        //Set the subject line
        $mail-&gt;Subject = $subject;
        //Read an HTML message body from an external file, convert referenced images to embedded,
        //convert HTML into a basic plain-text alternative body
        $mail-&gt;msgHTML($body/*file_get_contents('contents.html'), dirname(__FILE__)*/);
        //Replace the plain text body with one created manually
        $mail-&gt;AltBody = 'This is a plain-text message body';



        if ($stringAttachments != NULL) {
            if ($fileName == NULL) {
                $fileName = "report";
            }
            $mail-&gt;addStringAttachment($stringAttachments , $fileName.".pdf");
        }

        //send the message, check for errors
        if (!$mail-&gt;send()) {
            echo "error: " . $mail-&gt;ErrorInfo;
        } else {
            return "sent";
        }
    }
</code></pre>

<p>When I send an e-mail with a pdf attached (also in hebrew) it works just fine.
I thought I'd save a temp file, and then send it, but then I discovered that I can view the file proparly only from the browser.  </p>