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 188.8.131.52) onwards in WPF applications and the 2018 Volume 1 SP1 release (version 184.108.40.206) in UWP applications. The following are some of the use case scenarios in which the interactive form filling using PDF viewer can be useful:
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 220.127.116.11) onwards in WPF applications and the 2018 Volume 1 SP1 release (version 18.104.22.168) 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.
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 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!