Remote CSS & Images

763 views
Skip to first unread message

Paul Skinner

unread,
Dec 6, 2010, 11:52:28 AM12/6/10
to dompdf
Now, I know this has been covered a million and one times around here,
but I cannot for the life of me get remote images and CSS to work.

I have set this:

define("DOMPDF_ENABLE_REMOTE", true);

and this is the code I'm using to call dompdf

require_once("dompdf_config.inc.php");

if(isset($_GET['page_url']))
{
$pageurl = $_GET['page_url'];
}

if(isset($_GET['base_url']))
{
$baseurl = $_GET['base_url'];
}

$html = file_get_contents('http://eorailway.co.uk/index.php');

$dompdf = new DOMPDF();
if(isset($baseurl)){$dompdf->set_base_path($baseurl);}
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("sample.pdf");

So I'm calling it in the following way
http://urltoprocessor.com/index.php?base_url=http%3A%2F%2Feorailway.co.uk&page_url=http%3A%2F%2Feorailway.co.uk%2Findex.php

$html is outputting fine, so it's not that. I get a PDF containing the
website but without any images or CSS applied.

I'm using DomPDF 0.6.0 Beta 1

and yes, I know this is an insecure way of doing it.

BrianS

unread,
Dec 10, 2010, 2:22:10 PM12/10/10
to dompdf
Actual usage would be something like this:

$dompdf = new DOMPDF();
$dompdf->set_protocol('http://');
$dompdf->set_host('eorailway.co.uk');
$dompdf->set_base_path('/');
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("sample.pdf");

Obviously you'll have to split up the variables in your query or parse
the passed URL.




On Dec 6, 11:52 am, Paul Skinner <p...@paul-skinner.com> wrote:
> Now, I know this has been covered a million and one times around here,
> but I cannot for the life of me get remote images and CSS to work.
>
> I have set this:
>
> define("DOMPDF_ENABLE_REMOTE", true);
>
> and this is the code I'm using to call dompdf
>
> require_once("dompdf_config.inc.php");
>
> if(isset($_GET['page_url']))
> {
>         $pageurl = $_GET['page_url'];
>
> }
>
> if(isset($_GET['base_url']))
> {
>         $baseurl = $_GET['base_url'];
>
> }
>
> $html = file_get_contents('http://eorailway.co.uk/index.php');
>
> $dompdf = new DOMPDF();
> if(isset($baseurl)){$dompdf->set_base_path($baseurl);}
> $dompdf->load_html($html);
> $dompdf->render();
> $dompdf->stream("sample.pdf");
>
> So I'm calling it in the following wayhttp://urltoprocessor.com/index.php?base_url=http%3A%2F%2Feorailway.c...
Reply all
Reply to author
Forward
0 new messages