Dompdf: Unable to load HTML file when using Dompdf with Composer.

Created on 4 Mar 2016  路  4Comments  路  Source: dompdf/dompdf

In function loadHtmlFile(), there's these lines:

$chroot = $this->options->getChroot();
if (strpos($realfile, $chroot) !== 0) {
    throw new Exception("Permission denied on $file. The file could not be found under the directory specified by Options::chroot.");
}

When I'm using Dompdf with Composer, it lives in vendor directory, so the $chroot value is path/to/my/project/vendor/dompdf/dompdf but my code don't lives inside vendor. My file lives in path/to/my/project/src/myfile.html.

I also read Options.php is says about $chroot:

Prevents dompdf from accessing system files or other files on the webserver. All local files opened by dompdf must be in a subdirectory of this directory.

But I'm using Composer in this case, I don't want to put my file in vendor directory.

question

Most helpful comment

You can change the chroot path during instantiation, e.g.

$dompdf = new Dompdf();
$dompdf->set_option('chroot', '/path/to/document/root');

All 4 comments

You can change the chroot path during instantiation, e.g.

$dompdf = new Dompdf();
$dompdf->set_option('chroot', '/path/to/document/root');

Thanks!

Sorry to interrupt you. How could I possibly change the directory if the generated PDF has been downloaded? the default is on the download folder. I want to put it somewhere in my project file folder. Thank you.

@zander009 this type of question is more appropriate for the support forum.

That being said ... you can't. The location where the file is saved is entirely dependent on the client. You can't provide path information for a file download (it's a security risk).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SakaSerbia picture SakaSerbia  路  3Comments

Joshuavoosten picture Joshuavoosten  路  3Comments

AnarchyChampion picture AnarchyChampion  路  3Comments

halfer picture halfer  路  4Comments

OlegKorn picture OlegKorn  路  4Comments