Copied RSS Feed

PDF

Interactive Form Filling in Four Easy Steps

An interactive form, sometimes referred to as an AcroForm, is a collection of fields for gathering information interactively from the user. A PDF document may contain any number of fields appearing on any combination of pages, all of which make up a single, global interactive form spanning the entire document.

The Syncfusion PDF viewer for WPF and UWP platforms supports form filling, which allows the user to fill in and edit form fields. The user can save, print, and flatten the filled form. It is supported from the 2016 Volume 3 release (version 14.3.0.49) onwards in WPF applications and the 2018 Volume 1 SP1 release (version 16.1.0.32) in UWP applications. The following are some of the use case scenarios in which the interactive form filling using PDF viewer can be useful:

  • Event registration
  • Employment application
  • Car rental checklist

Here in this blog, we will look into filling an event registration form.

Fill the form in the PDF document

The PDF viewer supports filling and editing the following form fields:

  • Text boxes
  • Combo boxes
  • Radio buttons
  • Check boxes

The existing values of all these controls can be edited. PDF viewer also preserves tab order in navigating among the form fields when pressing Tab key.

Prepare a simple application with PDF viewer control by referencing the UG documentation and loading the event registration document. This document contains form fields to fill in basic details about the participant. Fill the form with the requested details.

Save the filled form

After entering the details, the save button in the toolbar can be used to save the filled form PDF document in a desired location. Once the saved document is opened in PDF viewer, the filled in information will persist in the document.

Print the filled form

In a similar fashion, the print button in the document toolbar can be used to print the filled PDF document using the viewer. On clicking or tapping the print button in the toolbar, a print dialog will be prompted, which is used to acquire the printer settings for printing the document.

Flatten and save the filled form

This feature can be used to transform an interactive PDF document into a noninteractive PDF. An interactive PDF document lets users enter or modify data that is in the PDF document fields. The process of transforming an interactive PDF document to a noninteractive PDF document is called flattening. When a PDF document is flattened, a user cannot modify the data in the document fields. One reason to flatten a PDF document is to ensure that data cannot be modified.

After filling the PDF document, the LoadedDocument property of the PdfViewerControl instance can be used to acquire the filled PDF document. Then, flattening the form fields and saving the PdfLoadedDocument object will result in a flattened PDF document. The below code snippet illustrates the same.

PdfLoadedDocument loadedDocument = pdfViewerControl.LoadedDocument;
loadedDocument.Form.Flatten = true;
loadedDocument.Save("Output.pdf");
loadedDocument.Close(true);

A sample demonstrating filling the form fields, saving, and printing them using the PDF viewer can be downloaded from here: FormFillingDemo.zip.

Summary

As you can see, the Syncfusion PDF viewer supports filling a variety of form fields in a PDF document. It also supports saving, printing, and flattening the filled PDF document.

If you’re already a Syncfusion user, you can download the product setup here. If you’re not yet a Syncfusion user, you can download a free, 30-day trial here.

If you have any questions or require clarification on these features, please let us know in the comments below. You can also contact us through our support forum or Direct-Trac. We are happy to assist you!

Meet the Author

Suresh M

Suresh is a Product Manager at Syncfusion and a technology enthusiast. He helps people follow best practices in coding and in using Syncfusion controls in their applications. Follow Syncfusion Blogs to learn and enhance your programming skills.