ByteScout PDF SDK - C# - Forms - Fill Form - ByteScout

ByteScout PDF SDK – C# – Forms – Fill Form

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF SDK – C# – Forms – Fill Form

ByteScout PDF SDK – C# – Forms – Fill Form

Program.cs

using System;
using System.Diagnostics;
using Bytescout.PDF;

namespace FillFormExample
{
    /// <summary>
    /// This example demonstrates how to fill PDF form programmatically.
    /// </summary>
    class Program
    {
        static void Main()
        {
            // Load PDF form
            Document pdfDocument = new Document(@"form.pdf");
            pdfDocument.RegistrationName = "demo";
            pdfDocument.RegistrationKey = "demo";

            Page page = pdfDocument.Pages[0];

            // Get widget by its name and change value
            ((EditBox) page.Annotations["editBox1"]).Text = "Test 123";
            ((EditBox) page.Annotations["editBox2"]).Text = "Test 456";
            ((CheckBox) page.Annotations["checkBox1"]).Checked = true;

            // Save modified document
            pdfDocument.Save("result.pdf");

            // Cleanup 
            pdfDocument.Dispose();

            // Open result document in default associated application (for demo purpose)
            ProcessStartInfo processStartInfo = new ProcessStartInfo("result.pdf");
            processStartInfo.UseShellExecute = true;
            Process.Start(processStartInfo);
        }
    }
}


  Click here to get your Free Trial version of the SDK

Tutorials:

prev
next