error with Autoloader

972 views
Skip to first unread message

Gustavo Contreras

unread,
Jan 27, 2016, 10:59:05 AM1/27/16
to dompdf
Hi everyone!

I'm new with dompdf, making a tutorial to make a single pdf, I have this:

in composer.json:

require "dompdf/dompdf" : "0.7.x@beta"

In index.php file:

require '../vendor/autoload.php';

require_once '../vendor/dompdf/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();

// Get the generated PDF file contents
$pdf = $dompdf->output();

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

When I run the php page, appears two errors:

 Warning: require_once(C:\wamp\www\ejemplocomposer\vendor\dompdf\dompdf/lib/php-font-lib/src/FontLib/Autoloader.php): failed to open stream: No such file or directory in C:\wamp\www\ejemplocomposer\vendor\dompdf\dompdf\autoload.inc.php on line 20

Fatal error: require_once(): Failed opening required 'C:\wamp\www\ejemplocomposer\vendor\dompdf\dompdf/lib/php-font-lib/src/FontLib/Autoloader.php' (include_path='.;C:\php\pear') in C:\wamp\www\ejemplocomposer\vendor\dompdf\dompdf\autoload.inc.php on line 20

I've been searching, but I'm confused, It's necessary modify the sentences require in the top of index.php file?

Thanks in advance.
--
Gustavo

Gh Occasions

unread,
Feb 12, 2016, 2:18:25 PM2/12/16
to dompdf
  • Go to https://github.com/PhenX/php-font-lib and download the library.
  • Create the dompdf/lib/php-font-lib/classes/ directory.
  • In the zip file, take the contents of the src/FontLib/ folder and paste that into your newly created directory.

BrianS

unread,
Feb 12, 2016, 5:09:45 PM2/12/16
to dompdf
Did you run composer install or composer update? Composer should take care of any dependencies such as php-font-lib. Also, once you've run composer you only need to include its autoloader, not the one included with dompdf. You only need the dompdf autoloader if you're using the downloadable package.
Reply all
Reply to author
Forward
0 new messages