lundi 28 septembre 2015

TCPDF Laravel Email Attachments

TCPDF doesn't seem to be working well with either $dest option ("E" or "S") for sending PDF attachments in Laravel 5.1. Files are always corrupt with an error upon launching Acrobat Reader (error message: ... for example, it was sent as an email attachment and wasn't correctly decoded). Decoding seems ok when I try another PDF generator like DOMPDF.

$pdf = new \TCPDF('P', 'in', 'LETTER', true, 'UTF-8', false);
$pdf->WriteHTML(view('emails.receipt_pdf', $receipt_data));
$attachment = $pdf->Output('Receipt - '.date("M-d-Y").'.pdf','E');

Mail::queue('emails.receipt_email', $receipt_data, function($message) use ($email, $attachment)
{
  $message->from('no-reply@website.com')
    ->to($email)
    ->subject('Receipt')
    ->attachData($attachment, 'Receipt.pdf');
});



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire