mccarlosen / laravel-mpdf

Generate PDFs in Laravel with Mpdf.
402 stars 107 forks source link

How we can run Javascript before making PDF #58

Closed usmanibrahim74 closed 3 years ago

usmanibrahim74 commented 3 years ago

I have to convert the timestamp into a local timestamp. so I need to run some javascript to do it. but didn't find any way. mpdf I think allows you to set some options to enable javascript. how we can do it in this package

maximus1127 commented 3 years ago

have you ever figured out how to do this? same issue for me.

mccarlosen commented 3 years ago

You can use the $mpdf->SetJS() method to run Acrobat Javascript. Only Acrobat Javascript is supported.

Example:

// ...
$mpdf = $pdf->getMpdf();
$mpdf->SetJS('app.alert("Hello World")');

This will only work after generating the pdf file. You can visit: Acrobat Javacript Guide

mccarlosen commented 3 years ago

There has been no further interaction on this topic. It closes, but you can open it at any time.

jasim6423 commented 2 years ago

Hi,

I want to add an Image to the pdf with a hyperlink (using javascript) which will open the website in the browser when a user clicks the image. Can you please advise?