Is there a method to convert a html page into pdf and attach pdf in email without save the pdf to storage?

Published 11 months ago by Crazylife

I am using this method to send email


I want to convert a html page to pdf format and send via email as attachment. Is there any method i can use for perform this?

11 months ago (246,030 XP)

Have you gone to and read their documentation?


@jlrdw Can i convert it and send directly without store the pdf file somewhere else?


It seems that you can do it.

You can create a new DOMPDF instance and load a HTML string, file or view name. You can save it to a file, or stream (show in browser) or download.



@tisuchi i tried something like

   $pdf = PDF::loadHtml(URL::to(......));
   $m->attachData($pdf->output(), 'abc.pdf', ['mime' => 'application/pdf']);

When email sent out, the attachment is blank and only with the url link, is my way correct to make the html as pdf and send as email attachment?


It seems correct. As long as you are getting the pdf file, that should be fine.

Please sign in or create an account to participate in this conversation.