DOMPDF Error generating pdf

Asked

Viewed 567 times

-1

I do the same code that the DOMPDF documentation teaches but when I open the page it gives an error of

"Error Failed to load PDF document."

Can anyone help? This is the code I’m putting

<?php

require_once 'lib/dompdf/autoload.inc.php';


 use Dompdf\Dompdf;

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

 // (Optional) Setup the paper size and orientation
  $dompdf->setPaper('A4', 'landscape');

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

// Output the generated PDF to Browser
$dompdf->stream("realacao",array("Attachment"=>false));



 ?>

1 answer

0

basically the mistake you made was when you inserted autoload into your code.

instead:

require_once 'lib/dompdf/autoload.inc.php';

use this:

require_once 'vendor/autoload.php';

this way you will be using the default autoload generated by Composer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.