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)
+1 on iTextSharp. As to the fields being lost on save, it is worth noting that Fox It Reader is free and allows saving editable PDFs. If that isn't an option then it is usually Acrobat Standard at most companies. You could use any number of PDF print drivers and print the edited PDF form to PDF though it will be readonly at that point (still of some use in cases).