I have a custom module that allows customer to returns the product. Everything working fine and i want to generate a label pdf to paste in the return box.I tried below approach and i am getting error. I used dompdf.

require_once 'dompdf/autoload.inc.php';
use Dompdf\Dompdf;
$pdfName = "unique_file_name";
$html = "My Printing Label Goes Here";

// instantiate and use the dompdf class
$dompdf = new Dompdf();

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

// Render the HTML as PDF

// Output the generated PDF to Browser 

Uploaded the dompdf library to my lib folder.

I am getting an error in system.log. The error is as follow:

ERR (3): Warning: include(Dompdf\Dompdf.php): failed to open stream: No such file or directory  in C:\xampp\htdocs\my_project\lib\Varien\Autoload.php on line 94

But if I use the same folder out of the magento its working fine.

Can any one help me in this to short out please.


I copied the dompdf folder in to lib folder


You have included autoload.inc.php wrong way.

Assume that autoload.inc.php ds located at your magento application root dir(Example /var/www/html).


require_once 'dompdf/autoload.inc.php';


require_once Mage::getBaseDir('lib').DS.'dompdf'.DS.'autoload.inc.php';
| improve this answer | |
  • no i am located the dompdf package in to lib folder.so i can directly call like that right? – Mujahidh Mar 24 '17 at 11:58
  • Yes, you can load it directly – Amit Bera Mar 24 '17 at 12:02
  • @Amith Is there any way to generate a pdf file based on html in customer my account area? – Mujahidh Mar 24 '17 at 12:04
  • Magenot does not have default feature.You need to build own code – Amit Bera Mar 24 '17 at 12:07
  • $dompdf->stream($pdfName);` able to give u pdf content? – Amit Bera Mar 24 '17 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.