Search code examples
javascriptvb.netpdfadobeitext

iTextSharp: Javascript in PDF not firing when filled in in vb.Net


I use iTextSharp to fill in the PDF server-sided and return it so that the client can download it.

Here's the link to the pdf.

The problem is number 1. You can only fill in the PDF if you have one of the boxes checked. If none is checked, everything will be "empty". The content isn't removed and returns once a box has been checked.

Everything gets populated, but there is a problem. The checkbox gets checked, but the Javascript behind it doesn't fire. Any solutions?


Solution

  • When you use iText(Sharp) to fill in forms, Javascript events wont be triggered.

    Many events make no sense, no focus is gained or lost, no keys are typed, iText(Sharp) directly changes the PDF objects, it does not emulate a person filling in the forms.

    Furthermore, iText(Sharp) does not include a JavaScript execution environment with an Adobe Reader object model to begin with.


    Any solutions?

    While I wrote the above, @Bruno already explained in a comment that you can either

    • vote to get some kind of Javascript support on the roadmap of iText if you are a paying iText customer;
    • wait and hope other iText users who are iText customers vote that onto the roadmap if you are not a paying iText customer;
    • implement such a Javascript support into iText yourself; it's open source after all; but be aware of the viral iText license; or
    • analyze the Javascript in your PDF and hard code analogous operations into your code