Dompdf: Class 'Font_Metrics' not found

Created on 10 Nov 2015  路  4Comments  路  Source: dompdf/dompdf

I am trying to enable inline PHP but I get the following error,

Fatal error: Class 'Font_Metrics' not found in peadeff/vendor/dompdf/dompdf/src/PhpEvaluator.php(48) : eval()'d code on line 5

here is the code that I've used.

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

use Dompdf\Dompdf;

ob_start();
require "template.php";
$html = ob_get_clean();

$dompdf = new DOMPDF();
$dompdf->set_option( "is_php_enabled" , true ); // the faulty statement; otherwise pdf generation works

$dompdf->load_html( $html );
$dompdf->setPaper( "A4" , "potrait" );
$dompdf->render();

file_put_contents( "output.pdf" , $dompdf->output() );

how can I fix this?

EDIT:
actually this is the faulty line
$font = Font_Metrics::get_font( "verdana" , "bold" );
within the text/php block

documentation

Most helpful comment

In 0.7.0 FontMetrics class is now instantiated and available as $fontMetrics. The wiki will be updated when we merge the develop branch back in to master.

All 4 comments

In 0.7.0 FontMetrics class is now instantiated and available as $fontMetrics. The wiki will be updated when we merge the develop branch back in to master.

thanks.

I'll keep this issue open so we don't forget to update the wiki.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

halfer picture halfer  路  4Comments

SakaSerbia picture SakaSerbia  路  3Comments

OlegKorn picture OlegKorn  路  4Comments

fillmore-admin picture fillmore-admin  路  4Comments

enjibby picture enjibby  路  4Comments