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

sam defri's avatar

Can I use Js in dompdf

I need to use some javascript, jquery to do something inside my pdf blade file. but js is not working in pdf blade i tried the same thing in other view blade and it's working perfectly.

is there any way i can use js in pdf balde file which use to generate pdf view using dompdf thanks

0 likes
9 replies
Sinnbeck's avatar

Do you mean that the js should work inside the pdf so it's interactive? Or just edit the html before the pdf is generated

Sinnbeck's avatar

@zache09 I would think that to be possible yes. Check that your your js runs at all by doing something else, like add a red background

And be sure it's on the page and not in a separate js file

Sinnbeck's avatar

If you don't want to inline all of your js, perhaps consider switching to browsershot

Sinnbeck's avatar

@zache09 if you rewrite it to plain js it should work. Dompdf ignores the jquery script tag as it's external

Sinnbeck's avatar

@zache09 no. You would need to manually add all of jquery to a script tag on the page

Sinnbeck's avatar

@zache09 that might take some research. Did you try my suggestion with browsershot? It should just work

1 like

Please or to participate in this conversation.