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

DaemonKeen's avatar

Enable JavaScript in DomPDF?

Can I somehow use javascript inside DomPDF? I use this package https://github.com/barryvdh/laravel-dompdf and I found javascript option in the dompdf config file:

/**
         * Enable inline Javascript
         *
         * If this setting is set to true then DOMPDF will automatically insert
         * JavaScript code contained within <script type="text/javascript"> ... </script> tags.
         *
         * @var bool
         */
        'enable_javascript' => true,

I added my js:

<script type="text/javascript">
		//change header text to "hello world"
        document.getElementById('header_text').innerHTML = 'Hello World';
</script>

And it still doesn't do anything. Any ideas?

0 likes
0 replies

Please or to participate in this conversation.