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

VolkanOner's avatar

I cannot use spatie's Laravel PDF

My Controller:

// other codes...

		$name = 'invoice-' . $participant->id . '.pdf';

        $data = [
            'participant' => $participant,
            'total' => $total,
            'days' => $days,
            'destinations' => $destinations,
            'participation' => $participation,
            'submission_fee' => $submission_fee,
            'user' => $user
        ];

        Pdf::view('front.documents.invoice', $data)
            ->save($name);

-> Laravel PDF composer package installed -> npm install puppeteer executed

I tried these;

->setNodeBinary('/usr/local/bin/node') ->setNpmBinary('/usr/local/bin/npm');

I don't know if its important but i use herd on my MacBook.

AND I'M GETTIN THIS ERROR LIKE FOR 4 HOURS;

The command "PATH=$PATH:/usr/local/bin:/opt/homebrew/bin NODE_PATH=`npm root -g` node '/Users/is/Documents/GitHub/conference_system/vendor/spatie/browsershot/src/../bin/browser.cjs' '{"url":"file:\/\/\/var\/tmp\/1358724051-0570237001714435100\/index.html","action":"pdf","options":{"path":"invoice.pdf","args":[],"viewport":{"width":800,"height":600},"displayHeaderFooter":false,"printBackground":true}}'" failed. Exit Code: 1(General error) Working directory: /Users/is/Documents/GitHub/conference_system/public Output: ================ Error Output: ================ TimeoutError: Navigation timeout of 30000 ms exceeded at new Deferred (/Users/is/Documents/GitHub/conference_system/node_modules/puppeteer-core/lib/cjs/puppeteer/util/Deferred.js:59:34) at Deferred.create (/Users/is/Documents/GitHub/conference_system/node_modules/puppeteer-core/lib/cjs/puppeteer/util/Deferred.js:21:16) at new LifecycleWatcher (/Users/is/Documents/GitHub/conference_system/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/LifecycleWatcher.js:66:60) at CdpFrame.goto (/Users/is/Documents/GitHub/conference_system/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Frame.js:136:29) at CdpFrame.<anonymous> (/Users/is/Documents/GitHub/conference_system/node_modules/puppeteer-core/lib/cjs/puppeteer/util/decorators.js:98:27) at CdpPage.goto (/Users/is/Documents/GitHub/conference_system/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Page.js:585:43) at callChrome (/Users/is/Documents/GitHub/conference_system/vendor/spatie/browsershot/bin/browser.cjs:276:37)

Additionally;

I tried to switch Laravel DOMPDF package and it works but tailwind classes doesn't work on this package. I guess I have to write my own classes in style tag. There is so many pdf that I must create. Tailwind is a must in this circumstances.

OR ANY OTHER ADVICE

0 likes
2 replies
Amaury's avatar

@volkanoner I personally used to Barryvdh\DomPDF package and prefer writing the CSS in style tag.

Anyway, maybe you can write your css with Tailwind in your view templates. Then generate css in a separate file for each template and paste the css in the style tag of the template…

... Or maybe display your template in a navigator (easy to do with Laravel DomPDF), then copy the style from the inspector…

It’s seems to me too cumbersome and complicated.

I think it’s easier to write CSS…

1 like

Please or to participate in this conversation.