Question: Is it possible to edit the javascript of a pdf document with .net?

I've looked at the [Acrobat SDK](http://sourceforge.net/projects/itextsharp/), but without much luck. It looks like you can retrieve values from forms etc. but not edit the document.

Am I way off track? Is this even possible?

I've tried [iTextSharp](http://sourceforge.net/projects/itextsharp/), but since the pdf contains form fields, the fields are lost when I save the pdf.

Any suggestions?

Answer: 
Well, apparently you can with [iTextSharp](http://sourceforge.net/projects/itextsharp/):

```
        Document document = new Document(PageSize.A4, 50, 50, 50, 50);

        PdfReader reader = new PdfReader(@"Source.pdf");
        FileStream output = new FileStream(@"Destination.pdf", FileMode.Create);

        PdfStamper pdfStamper = new PdfStamper(reader, output, '\0', true);               
        pdfStamper.JavaScript = "app.alert(\"Hello world!\");";

        pdfStamper.FormFlattening = false;
        pdfStamper.Close();
        reader.Close();

```

([This question](https://stackoverflow.com/questions/209972/how-to-programmatically-inject-javascript-in-pdf-files) helped)
[PDF4NET](http://www.o2sol.com/pdf4net/overview.htm) can load PDF files and it gives you access to all JavaScript fragments, whether they are located at document level or at field/annotation actions level.

Disclaimer: I work for the company that develops PDF4NET.