How do I embed a javascript inside a pdf?

Q: We want to embed javascript inside a pdf.

In the faq is a small description but its refers to a PDF Reference
Manual that I don't find on your page.

So could you send me a simple example to embed javascript inside a
Something like open a pdf and add an 'alert' to the document. C# would
be great.
A: I assume that you are referring to the following FAQ:

You can download the PDF Reference Manual using the following link:

For example:

PDFDoc pdfdoc = PDFDoc(@"c:\mypdf.pdf");

Obj root = pdfdoc.GetRoot();
Obj aa = root.PutDict("AA");

Obj ds = pdfdoc.CreateIndirectDict();
Obj ws = pdfdoc.CreateIndirectDict();
Obj dc = pdfdoc.CreateIndirectDict();

// See Table 8.47 in PDF Reference.
aa.Put("DS", ds); // Did Save Action
aa.Put("WS", ws); // Will Save Action
aa.Put("DC", dc); // Document Close Action

ds.PutName("S", "JavaScript");
ds.PutString("JS", "alert(' DidSave');");

ws.PutName("S", "JavaScript");
ws.Puttring("JS", "alert(' OnSave ');");

dc.PutName("S", "JavaScript");
dc.PutString("JS", "alert(' OnClose ');");

doc.Save(@"c:\mypdf_modified.pdf", SDFDoc.SaveOptions.e_linearized);