Fatal error: Uncaught Dompdf\Exception

3,455 views
Skip to first unread message

Anushaath .P

unread,
Mar 30, 2017, 3:18:49 AM3/30/17
to dompdf
I'm Getting this when I load a file from any directory.

`Fatal error: Uncaught Dompdf\Exception: Permission denied on /pdfhtml.html. The file could not be found under the directory specified by Options::chroot. in C:\xampp\htdocs\dompdf\src\Dompdf.php:366 Stack trace: #0 C:\xampp\htdocs\dompdf\src\Dompdf.php(333): Dompdf\Dompdf->loadHtmlFile('/pdfhtml.html') #1 C:\xampp\htdocs\pdf.php(16): Dompdf\Dompdf->load_html_file('/pdfhtml.html') #2 {main} thrown in C:\xampp\htdocs\dompdf\src\Dompdf.php on line 366


I have seen that you've told us to change the setting  DOMPDF_CHROOT. But where do  I find and change this setting.

In my file  I've written

$options->set('chroot', 'C:\xampp\htdocs');

Still it shows this error.

 Please guide me where should i change the   DOMPDF_CHROOT setting.

I did a CTRL+F on Dompdf.php, and it showed no matches found.

BrianS

unread,
Mar 30, 2017, 9:50:44 AM3/30/17
to dompdf
In dompdf 0.8.0 the configuration constants are no longer used.

You're on the correct path for updating the settings, but if you're using the options class make sure you pass it in when constructing dompdf (ref):

use Dompdf\Dompdf;
use Dompdf\Options;
$options
= new Options();

$options
->set('chroot', 'C:\xampp\htdocs');

$dompdf
= new Dompdf($options);

You can also set it after instantiation (but before you load the document):

$dompdf->set_option('chroot', 'C:\xampp\htdocs');

Anushaath .P

unread,
Mar 31, 2017, 3:10:07 AM3/31/17
to dompdf
Now I got an error in the PhpEvaluator.php file.

I've written my php script inside the html file like
<?php    
.
.
 
?>

Is it wrong? Should I define it as <script type="text/php"> ? 
Message has been deleted

Anushaath .P

unread,
Apr 1, 2017, 2:34:41 AM4/1/17
to dompdf
Can I render a PHP file to PDF?
I'll have the HTML code inside the PHP file.
Is it possible?

BrianS

unread,
Apr 11, 2017, 6:28:56 PM4/11/17
to dompdf
I see you've posted in other topics ... are you still experiencing this issue?

Anushaath .P

unread,
Apr 13, 2017, 2:32:52 AM4/13/17
to dompdf
No. I've overcome the issue. Thanks.

akshay...@gmail.com

unread,
Oct 10, 2017, 8:46:11 PM10/10/17
to dompdf
Fatal error: Uncaught Dompdf\Exception: Permission denied on report-hash.php. in E:\www\reports\vendor\dompdf\dompdf\src\Dompdf.php:371 Stack trace: #0 E:\www\reports\download-pdf.php(18): Dompdf\Dompdf->loadHtmlFile('report-hash.php') #1 {main} thrown in E:\www\reports\vendor\dompdf\dompdf\src\Dompdf.php on line 371

I came to this issue, please help me.
Thank you.
dompdf-permission-error.PNG

BrianS

unread,
Oct 11, 2017, 10:38:50 AM10/11/17
to dompdf
the "chroot" option doesn't change the working directory. It only specifies the directory on the local file system from which you are allowed to fetch content. I think you want to change your HTML file reference to: $htmlContent = "../reports/report-hash.php";

I note that you're referencing a PHP file. Noting here just in case, Dompdf will not render the PHP so if that file is not straight HTML you won't get what you expect. You'll either want to include the file and use output buffering to capture the content or fetch the file via your web server.

Next time please post the code snippet as text rather than an image. It's easier to reference.
Reply all
Reply to author
Forward
0 new messages