HTML to PDF from a External URL

3,518 views
Skip to first unread message

Eduardo Chiaradia

unread,
Sep 22, 2016, 11:01:45 AM9/22/16
to dompdf
Hi guys, 

I need get a external url and convert to a pdf file, 
for example, convert the www.apple.com to a pdf file.

How I do this using domPDF in PHP?

Tks for 4,
Eduardo Chiaradia.

BrianS

unread,
Sep 26, 2016, 10:21:08 AM9/26/16
to dompdf
From the README (just replace loadHtml with loadHtmlFile):

// reference the Dompdf namespace use Dompdf\Dompdf;

// instantiate and use the dompdf class
$dompdf
= new Dompdf();
$dompdf
->loadHtmlFile('http://www.apple.com');

// (Optional) Setup the paper size and orientation
$dompdf
->setPaper('A4', 'landscape');

// Render the HTML as PDF
$dompdf
->render();

// Output the generated PDF to Browser
$dompdf
->stream();

Though, to be honest, dompdf probably won't be able to render apple.com very well.

Also helpful is the Usage documentation in the wiki.
Reply all
Reply to author
Forward
0 new messages