How do I extract the JavaScript from a bookmark in PDF?

Q: How do I extract the JavaScript text from a bookmark? (I would
like to parse it) I have been trying to extract the text but had no
had luck so far - I only found how to add it. Any help is
A: You can extract JavaScript from an action that is associated with a
bookmark. For example:

Action action = bookmark.GetAction();
if (action.IsValid() && action.GetType() == Action::e_JavaScript) {
  // Extract embedded JavaScript...
  Obj js = action.GetSDFObj().FindObj("JS");
  if (js != null) {
    if (js.IsString()) { // JS can be stored as a text string or a
      string java_script = js.GetAsPDFText();
    else {
      Obj stm = js.GetDecodedStream();
      // FilterReader reader = new FilterReader(stm);
      // reader.Read(...extract JS ....);