ByteScout PDF SDK - C# - Fill Form W-4 - ByteScout

ByteScout PDF SDK – C# – Fill Form W-4

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF SDK – C# – Fill Form W-4

fill form W 4 in C# using ByteScout PDF SDK

How To: tutorial on fill form W 4 in C#

ByteScout tutorials explain the material for programmers who use C#. ByteScout PDF SDK was made to help with fill form W 4 in C#. ByteScout PDF SDK is the pdf library that can create, update and modify PDF files. Supports text with fonts and style selections, layers, form fields, drawing lines and objects, automatic tables, images. Can be used to create and fill pdf forms.

You will save a lot of time on writing and testing code as you may just take the code below and use it in your application. Follow the instruction from the scratch to work and copy and paste code for C# into your editor. Test C# sample code examples whether they respond your needs and requirements for the project.

Trial version can be obtained from our website for free. It includes this and other source code samples for C#.

Try ByteScout PDF SDK today: Get 60 Day Free Trial or sign up for Web API

Program.cs
      
using System; using System.Collections.Generic; using System.Diagnostics; using Bytescout.PDF; namespace FillFormExample { /// <summary> /// This example demonstrates how to fill PDF form programmatically. /// </summary> class Program { static void Main() { // Map of form fields and sample values to set Dictionary<string, object> fieldMap = new Dictionary<string, object>() { { "f1_01[0]", "John J" }, // FirstName and middle initial { "f1_02[0]", "Smith" }, // LastName { "f1_03[0]", "111-111-3333" }, // Security number { "f1_04[0]", "12 Palm st., Hill Valley" }, // Home address { "f1_05[0]", "CA 12345" }, // City, Town, State and ZIP { "c1_1[1]", "True" }, // Married { "f1_06[0]", "123" }, // Total number of allowance { "f1_07[0]", "443.44" }, // Additional amount { "f1_09[0]", "Google, Somewhere in CA" }, // Employer's name and address { "f1_10[0]", "12-3-2012" }, // First date of employment { "f1_11[0]", "EMP223344" } // Employer identification number }; // Load PDF form Document pdfDocument = new Document(@".\W-4.pdf"); pdfDocument.RegistrationName = "demo"; pdfDocument.RegistrationKey = "demo"; // Get first page Page page = pdfDocument.Pages[0]; // Get widget by its name and change value foreach (KeyValuePair<string, object> keyValuePair in fieldMap) { Annotation annotation = page.Annotations[keyValuePair.Key]; if (annotation is CheckBox) { ((CheckBox)annotation).Checked = Convert.ToBoolean(keyValuePair.Value); } else if (annotation is EditBox) { ((EditBox)annotation).Text = (string)keyValuePair.Value; } } // 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); } } }

Try ByteScout PDF SDK today: 60 Day Free Trial (on-premise version) or sign up for Web API (on demand version)

VIDEO

ON-PREMISE VERSION

Get 60 Day Free Trial or Visit ByteScout PDF SDK page

Explore ByteScout PDF SDK documentation

WEB API

Sign Up for free Web API key

Explore Web API Documentation

Tutorials:

prev
next