You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You certainly can. However, pdf-lib doesn't have any special APIs for this, so you'll have to use the lower-level APIs. Here's a basic example demonstrating how to create a JavaScript action dictionary with pdf-lib:
import{PDFDocument,PDFHexString}from'pdf-lib';constpdfDoc=awaitPDFDocument.create()constjsActionDict=pdfDoc.context.obj({Type: 'Action',S: 'JavaScript',JS: PDFHexString.fromText(` // Insert the JavaScript you want to embed here... `),})// Now use the `jsActionDict`...
See section 12.6.4.16 JavaScript Actions of the PDF spec for more details about JavaScript action dictionaries and how to use them.
Is there a way to embed Javascript into a PDF using
pdf-lib
?The text was updated successfully, but these errors were encountered: