FriendsOfCake/CakePdf

CSS is not being applied

smarek opened this issue · 5 comments

CakePHP 3.7.7, PHP 7.3 (debian stretch, php7.3 7.3.4-2), wkhtmltopdf engine (debian 0.12.5-1)
composer installed cakepdf version 3.5.2

layout:

<!DOCTYPE html>
<html>
<head>
    <?= $this->Html->charset() ?>
    <title>
    </title>
    <?= $this->Html->css('bootstrap.min.css', ['fullBase' => true]) ?>
</head>
<body>
<div class="container-fluid clearfix">
    <?= $this->fetch('content') ?>
</div>
</body>
</html>

In view file, there is no css/script include/fetch declaration, only one <style type="text/css"> inlined

in Application plugin loaded using $this->addPlugin('CakePdf'); and used in action/view with configuration

    public function exportTable()
    {
        Configure::write('CakePdf', [
            'engine' => 'CakePdf.WkHtmlToPdf',
            'orientation' => 'landscape',
            'download' => false
        ]);

        if (!empty($this->request->getQuery('pdf'))) {
            $this->viewBuilder()->setClassName('CakePdf.Pdf');
            $this->viewBuilder()->setTemplate('/Wizard/export_table');
        }

        $data = [...];
        $this->set(compact('data'));
    }

I had to replace the bootstrap css import with this, to get it working:

    <style type="text/css">
        <?= file_get_contents(WWW_ROOT.'css'.DS.'bootstrap.min.css') ?>
    </style>

Unfortunately, there is nothing in the logs, and I'm not sure how to collect additional relevant debugging info for this plugin, if you advise me, i'll try to provide

ADmad commented

If you are generating the PDFs through CLI you'll have to set the App.fullBaseUrl config for URLs for assets to be generated properly.

@ADmad i'm not generating through CLI, and App.fullBaseUrl is set, contains correct URL address.

ADmad commented

Well then you'll have to debug the issue yourself and submit a fix if needed.

Whole point was to get a guidance on debugging, since there is no debug output in PDF meta/contents or HTTP headers, and the whole thing works flawlessly when rendering HTML

ADmad commented

Sorry but I don't have the time to try and help you debug the problem. Trying using one of CakePHP's support forums for help.