PDF Download Problem

$dompdf->render();
this function not working. please help

Hi biplabpramanik,

Please share the full set of code that is related to this render with the error message so we can help with the issue thanks.

Cheers!

3 Likes
<?php

$html = ob_get_clean();

$dompdf = new Dompdf();

$dompdf->setPaper('A4', 'portrait');

$dompdf->load_html($html);

$dompdf->render();

$cpdf = $dompdf->getCanvas()->get_cpdf();

$cpdf->setEncryption($pan,$pan,'print','modify','copy','add');

$pdf = 'PAYSLIP FOR '.$row2['NAMEOFTHETEACHER'].' OF '.$row2['NAMEOFTHESCHOOL'].'.pdf';

#Output the generated PDF to Browser

//$infoB4 = $cpdf->objects[$cpdf->arc4_objnum]['info'];

//$dompdf->stream($cpdf);

$dompdf->stream($pdf);

//$cpdf->objects[$cpdf->arc4_objnum]['info'] = $infoB4;

$output = $dompdf->output();

?>

Hi biplabpramanik,

Would you please format the code and proive the error message? Thanks

Cheers

1 Like

Fatal error : Uncaught Dompdf\Exception: file_get_contents(): Passing null to parameter #2 ($use_include_path) of type bool is deprecated 8192 in /home/vol15_2/epizy.com/epiz_24136231/sinalhatiwest.epizy.com/htdocs/Staff/dompdf/src/Helpers.php:507 Stack trace: #0 [internal function]: Dompdf\Helpers::record_warnings(8192, ‘file_get_conten…’, ‘/home/vol15_2/e…’, 838) #1 /home/vol15_2/epizy.com/epiz_24136231/sinalhatiwest.epizy.com/htdocs/Staff/dompdf/src/Helpers.php(838): file_get_contents(‘/home/vol15_2/e…’, NULL, NULL, 0) #2 /home/vol15_2/epizy.com/epiz_24136231/sinalhatiwest.epizy.com/htdocs/Staff/dompdf/src/Css/Stylesheet.php(363): Dompdf\Helpers::getFileContent(‘/home/vol15_2/e…’, NULL) #3 /home/vol15_2/epizy.com/epiz_24136231/sinalhatiwest.epizy.com/htdocs/Staff/dompdf/src/Dompdf.php(567): Dompdf\Css\Stylesheet->load_css_file(‘/home/vol15_2/e…’, 1) #4 /home/vol15_2/epizy.com/epiz_24136231/sinalhatiwest.epizy.com/htdocs/Staff/dompdf/src/Dompdf.php(719): Dompdf\Dompdf->processHtml() #5 /home/vol15_2/epizy.com/epiz_24136231/sinalhatiwest.epizy.com/htdocs/Staff/pdf.php(368): Dompdf\Dompdf->render() #6 {main} thrown in /home/vol15_2/epizy.com/epiz_24136231/sinalhatiwest.epizy.com/htdocs/Staff/dompdf/src/Helpers.php on line 507

Which version of DomPDF do you use? It seems like the version you’re using is too old to run on PHP 8.2.

If you’re not using the latest version, you really should. Looking at the available versions, it seems that all but the latest versions have known security problems.

9 Likes

Hi biplabpramanik,

While admin has more info than I do to determine your version of DomPDF used, this error message means that the library has attempted to get a file from a path that is not defined. This is caused by the library not checking the file path enough to see if it’s indeed accessible.

By reviewing your code, you have attempted to call this library to create an encrypted version of the payslip on the fly and offer a download upon request. However, you have not created any code to check if the $pdf exists in your directory. When the library attempts to get the $pdf, it also fails to check for the file’s existence and attempts to read it, hence causing the error.

Whether you upgrade the library or not, you still have to check for the file’s existence and whether the path leads to a valid PDF file before offering a download.

Cheers!

2 Likes