Of course, the javascript of a PDF document can be edited.
I do not know how this can be done in other libraries, but Docotic.Pdf (I work for Bit Miracle), you can add / remove / edit javascript actions for controls, pages and the document as a whole.
Here is an example of setting and modifying a javascript action. The code assumes that the document contains a button.
PdfDocument doc = new PdfDocument("document-with-button.pdf"); // assume that first widget is a button PdfButton button = doc.Widgets[0] as PdfButton; // add javascript action for OnMouseEnter event PdfJavaScriptAction action = doc.CreateJavaScriptAction("app.alert('OnMouseEnter JavaScript Action',3)"); button.OnMouseEnter = action; // change javascript action for OnMouseEnter event (button.OnMouseEnter as PdfJavaScriptAction).Script = "app.alert('Well, hello from OnMouseEnter JavaScript Action',3)"; doc.Save("output.pdf");
source share