php – I am unable to get the dompdf lib to work in wordpress-ThrowExceptions

Exception or error:

Hi i am developing a wordpress plugin that will generate pdf from html document and am trying to implement the dompdf for this purpose. But i keep getting error:

Uncaught Error: Class ‘Dompdf’ not found in

Below is my code:

function generate_certificate()
{

// include autoloader
require_once 'dompdf/autoload.inc.php';

// reference the Dompdf namespace
use Dompdf\Dompdf;

// instantiate and use the dompdf class
 $dompdf = new Dompdf();
$dompdf->loadHtml('hello world');


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

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

}
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *