Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

UsmanBasharmal's avatar

Creating pdf with cakephp 3 and doompdf, the pdf is not being generated

I'm Brazilian and I'm trying to create PDF reports with cakephp3 and doompdf but the pdf is not being generated, just the html, I am weak in programming can someone help me, follow the codes:

bootstrap.php

 Plugin::load('Dompdf');

routes.php

Router::scope('/', function ($routes) {

 $routes->extensions(['pdf']);

 });

controller

   public function pdf() {
   $this->viewBuilder()
  ->className('Dompdf.Pdf')
   ->layout('Dompdf.default')
  ->options(['config' => [
'filename' => 'voluntariopdf',
'render' => 'download',
 ]]);
 }

view

  <?php $this->start('header'); ?>
  <p>Header.</p>
  <?php $this->end(); ?>

  <?php $this->start('footer'); ?>
  <p>Footer.</p>
  <?php $this->end(); ?>


  <h1>Teste</h1>

 <p>Teste</p>

 <p>teste</p>

the html is being generated normally but the pdf is not, does anyone know where the error is?

0 likes
2 replies
vincent15000's avatar

Hello ... I think it is a forum for Laravel and not for CakePHP ;).

I would have helped you, but I don't know CakePHP.

Please or to participate in this conversation.