<?php
if (!isset($filename)){
    $filename = "Download";
}


$content_for_layout = $this->fetch('content'); //echo $content_for_layout;exit;


header ("Content-Disposition: attachment; filename=\"$filename.pdf" );
require_once(ROOT .DS. 'vendor' . DS . 'dompdf' . DS . 'autoload.inc.php');
//spl_autoload_register('DOMPDF_autoload');
use Cake\Core\Configure;
use Dompdf\Dompdf;
$dompdf = new Dompdf();
$dompdf->set_option('isRemoteEnabled', TRUE);
$dompdf->setPaper("a4", "portrait");
$dompdf->loadHtml(utf8_decode($content_for_layout), Configure::read('App.encoding'));
$dompdf->render();
$output = $dompdf->output();
file_put_contents('pdf'. DS .'manual'. DS .$filename.'.pdf', $output);

?>