PHP code example of dompdf / dompdf

1. Go to this page and download the library: Download dompdf/dompdf library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.

/* Start to develop here. Best regards */


dompdf / dompdf example snippets

// somewhere early in your project's loading, d

// include autoloader

// reference the Dompdf namespace
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

// Output the generated PDF to Browser

use Dompdf\Dompdf;
use Dompdf\Options;

$options = new Options();
$options->set('defaultFont', 'Courier');
$dompdf = new Dompdf($options);

use Dompdf\Dompdf;

$dompdf = new Dompdf();
$options = $dompdf->getOptions();

     $html = '<img src="data:image/svg+xml;base64,' . base64_encode($svg) . '" ...>';