FriendsOfCake / CakePdf does not read the css file

What I did:

  1. installed the plugin with composer require friendsofcake/cakepdf

  2. installed dompdf with composer require dompdf/dompdf

  3. loaded the plugin with ./bin/cake plugin load CakePdf

  4. changed routes.php (added the last 3 lines)to

    $routes->scope('/', function (RouteBuilder $builder) {
        $builder->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);
        $builder->connect('/pages/*', 'Pages::display');
    $routes->prefix('Admin', function (RouteBuilder $routes) {
    //for pdf plugin:
    $routes->scope('/', function (\Cake\Routing\RouteBuilder $routes) {
  1. added this to bootstrap.php:
Configure::write('CakePdf', [
    'engine' => 'CakePdf.DomPdf',
    'margin' => [
        'bottom' => 15,
        'left' => 50,
        'right' => 30,
        'top' => 45
    'orientation' => 'landscape',
    'download' => true
  1. created a function in my controller
class UsersController extends AppController

    public function initialize(): void

    public function beforeRender(\Cake\Event\EventInterface $event)

        if ($this->request->getAttribute('identity')->userrole_id <> 2) {
          return $this->redirect(['prefix'=>false,'controller'=>'Users','action'=>'logout']);

    public function createpdf($id = null)
        $user = $this->Users->get($id, [
            'contain' => ['Userroles', 'Departments', 'Companyroles', 'Userstatuses'],
                'orientation' => 'portrait',
                'download' => true, // This can be omitted if "filename" is specified.
                'filename' => 'Usertestpdf_' . $id // This can be omitted if you want file name based on URL.
    }//rest of users controller not shown....
  1. created a file named “createpdf.php” in “templates/Admin/users/pdf/”. It has the same content as my view.php
  2. created a file named “haas.php” in “templates/layout/pdf”:
<!DOCTYPE html>
    <?= $this->Html->charset() ?>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
      echo $this->Html->css('haas.css', ['fullBase' => true]);
      echo $this->fetch('css');;

<header class="row">
<div class="">
    <div class="text-5xl">
          echo $this->fetch('content')

When I go to http://localhost/haas/admin/users/createdpdf/1 the pdf is created, but it is missing all the defined styles from my css named “haas.css”

Can someone see what I did wrong or where im thinking wrong?
If you need more information, please let me know

After having some sleep, I think I found a solution:
My css is generated with tailwind and at the moment it is really a big file which take a long time to load. After creating a new (slim) css file it works.