PDFOne .NET
Powerful all-in-one PDF library for .NET
Compatibility
VS 2005/2008/2010/2012/2013

Create PDF Forms With Fill-One, Update-Many Form Fields

“Is there a way to add a form field to all pages in a PDF document so that updating the field in any one page automatically gets reflected in all other pages?”
By M. V. Niranjan

One of our customers had a PDF document with several pages, each containing a set of form fields. While most of the form fields contained values that were different across pages, there were a few form fields that needed to have the same value on all pages. Our customer just wanted to fill a field on one page and have the change reflected on all the other pages.

For example, imagine a PDF document with a form in each page. There is field where date is entered. If the document has say 100 of page, users may not want to enter the same date in all the 100 pages!

How It Works

Our solution involved adding several form fields with same FieldName. An important requirement for this solution to work is to set the ApplyFormAppearances* property of the PDFDocument object to true.

Code Snippet

PDFDocument doc = new PDFDocument();

// Create a text field
PDFFormTextField txt = new PDFFormTextField();
txt.FieldName = "TextField";
txt.FieldValue = "Type here";
txt.Rectangle = new RectangleF(6, 0.27f, 2, 0.5f);
txt.BorderWidth = 2;
txt.BorderColor = Color.LightBlue;
txt.BackgroundColor = Color.White;

// Creates several text fields all with 
// the same name and adds them to different 
// pages
for (int i = 0; i < 8; i++)
{
  // Creates a new PDF page
  PDFPage page = new PDFPage();

  // Clones text field and adds it to the page
  page.AddFormField((PDFFormField)txt.Clone());

  // Adds the page to the document
  doc.AddPage(page);
}

doc.OpenAfterCreate = true;

// Specifies that viewer should provide an appearance 
// style for the fields
doc.ApplyFormAppearances = true;
// Saves changes to output PDF file
doc.Save("Forms.pdf");
doc.Close();

* - ApplyFormAppearances determines whether viewer application or the PDF document provides a visual appearance style for the form field. For form fields that do not have any content and whose content will not be known until the user enters some text, the viewer application will have to provide the visual appearance style for the fields, as the PDF document cannot provide a static visual appearance style in such cases.

---oO0Oo---

Downloads

---o0O0o---

Our .NET Developer Tools
XtremeDocumentStudio .NET

Multi-format document-processing component suite for .NET developers.

PDFOne .NET

A .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications.

Our Delphi/C++Builder developer tools
XtremeDocumentStudio Delphi

Multi-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms.

eDocEngine VCL

A Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools.

PDFtoolkit VCL

A Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents.

Our Java developer tools
XtremeDocumentStudio (for Java)

Multi-format document-processing component suite for Java developers.

PDFOne (for Java)

A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications.

Our Platform-Agnostic Cloud and On-Premises APIs
StarDocs

Cloud-hosted and On-Premises REST-based document-processing and document-viewing APIs

Privacy | Legal | Feedback | Newsletter | Blog | Resellers © 2002-2017 Gnostice Information Technologies Private Limited. All rights reserved.