PDFRasterizer.NET 4.0 is now available. Supports .NET Core. Renders pixel-perfectly.

Disable submit button after submitting

The following code adds a JavaScript action to a submit button that will disable the button after submitting.

using System.IO;

using TallComponents.PDF;
using TallComponents.PDF.Actions;
using TallComponents.PDF.Forms.Fields;
using TallComponents.PDF.JavaScript;

namespace DisableSubmitButton
    class Program
        static void Main(string[] args)
            string path = @"..\..\submit-button.pdf";

            using (FileStream fileIn = File.OpenRead(path))
                Document document = new Document(fileIn);

                string name = "Submit";
                PushButtonField button = document.Fields[name] as PushButtonField;
                button.Widgets[0].MouseUpActions.Add(new JavaScriptAction {
                    JavaScript = new JavaScript($"this.getField('{name}').readonly = true;")

                using (FileStream fileOut = File.OpenWrite(@"..\..\disable-submit-button.pdf"))
Download PDFKit.NET 4.0
We will send you a download link

  • This field is for validation purposes and should be left unchanged.
Why do we ask your email address?
We send tips that speed up your evaluation
We let you know about bug fixes
You can always unsubscribe with one click
We never share your address with a 3rd party
Thank you for your download

We have sent an email with a download link.