Working with PDF AcroForms
23 Jun 20212 minutes to read
PDF Viewer supports adding/modifying the existing forms fields content present in the PDF document. By default, it detects the form fields present in the PDF document and enables modifying or filling the values.
How to restrict editing the form field values in the existing PDF document
By setting the
EnableFormFilling property of the PdfViewerControl instance to false, you can avoid modifying the values of the form field elements present in the loaded PDF document.
//Does not load the form fields in PDF viewer pdfViewerControl.EnableFormFilling = false;
By default, the EnableFormFilling property is set to true.
How to flatten and save the form fields data
Flattening PDF form is a process of removing the form fields in the PDF document, thereby rendering the form fields appearance and its content in the page graphics. This will avoid the PDF form being edited in any device. PDF Viewer supports flattening the PDF form when saving. You can perform this action by passing the parameter
true to the Save method of PDF Viewer.
//Flatten and save the form fields during saving process pdfViewerControl.SaveDocument(true);
Rendering the appearance content of signature form fields
By default, the PDF viewer does not display the appearance content of signature form fields. But the appearance can be displayed by flattening the signature form fields before loading the PDF. This can be achieved by setting the
FlattenSignatureFields property as true. The default value of the property is set as false.
//Sets a value whether the signature form fields should be flattened when the PDF is loaded or not. pdfViewerControl.FormSettings.FlattenSignatureFields = true; //Loads the PDF. pdfViewerControl.LoadDocument(stream);
Signature form fields are only flattened when the page displayed in the viewer is only for viewing the appearance of signature form fields. Once the signature form fields are flattened, the interactions such as select, edit, resize, and remove cannot be performed. Setting the
truewill does not affect the save and form field export operations. The signature form fields will not be flattened in these operations.