How to remove JavaScript in PDF
You can use the pdf/makeunsearchable
that takes input PDF and re-prints this input PDF as new PDF that will contain no bookmarks/actions/javascripts. Please check this page for more details https://apidocs.pdf.co/11-pdf-make-text-searchable-or-unsearchable#post-pdfmakeunsearchable