请参考以下代码:
JavaScriptAction javascipt_action = new JavaScriptAction(Action.create(doc, Action.e_TypeJavaScript));
javascipt_action.setScript("app.alert(\"Hello Foxit \");");
AdditionalAction aa = new AdditionalAction(doc);
aa.setAction(AdditionalAction.e_TriggerDocWillClose, javascipt_action);
aa.doJSAction(AdditionalAction.e_TriggerDocWillClose);