Search

Auto-fill multiple Word Documents using Online Forms in WordPress

    Ankit Shah
Listen to this article

document-automationSites which offer an online form, usually provide ways to save them as PDFs, or an option to email the content. A client recently had a form automation requirement on WordPress, to auto-fill details entered in an online form into one or multiple word documents, upon request. Auto-filling multiple word documents, was a very interesting and novel feature we had to provide.

This article will give you an overview, of how to auto-fill multiple word documents.

 

Let’s begin with a general idea of the requirement

Consider an Insurance Company or a Legal Firm, which maintains client records. It is understandable that several client details, such as name, address, etc., would be repeated across several forms. In such cases, the requirement is to use the data entered by a client using an online form, to fill multiple word documents, which are accessible to the company administrators, upon request. Thus, the requirements were quite specific.

  • The client needed the flexibility to create and offer forms online.

  • The client can uploaded created word document templates. The fields in the document template will be mapped to the fields of the online form. Moreover, each online form can be mapped to one or more word documents.

  • When a visitor to the client site, enters data in the online form, this data will be saved to the database and will be used to auto fill the fields of the mapped word documents.

  • The client has an option to download the mapped word documents or to email them as attachments.

 

Before we continue…

Now, you could ask why we don’t just auto-generate the word document. We have to understand the use case in a bit more detail. The client needed the data from the online form saved in the database, to be retrieved at a later point in time, not immediately. Additionally, the mapping from the online form to the word document is not a one-to-one mapping. That is to say, one online form will be mapped to one or more word documents, and the fields to be mapped might be in different places.

 

To implement our functionality, we made use of the following:

  1. Gravity Forms WordPress plugin, to allow creation of the online forms. The Gravity Forms plugin provides a simple to use interface, and has many advanced features to create any kind of form needed. The plugin also saves all entries in the WordPress database for easy access.

  2. PHPWord Library to auto-fill word documents.

 

[space]
[space]

How to Auto-Fill Information from Gravity Forms to Word Document

We created a plugin as a part of the form automation system. This plugin was created as an add-on to the Gravity Forms Plugin, to upload and map word document templates, and the auto-fill functionality.

The client would have to create an online form using the Gravity Forms plugin. While creating a form, the client needs to enter unique names for the form fields. These names will be used to map the form fields to the word document fields.

Our form automation plugin provided the following:

  • Option to Upload Word Document Templates: The client has an option to upload and save the Word Document Templates, he creates. Each field in the word document template, should have the form field names in the corresponding placeholders.

  • Page for mapping an online form to the word document(s): Since one or more word documents might be mapped to a single online Gravity form, the client needed an option to manually decide and map the online form to the word document(s). This mapping will be saved in the database.

  • Document Generation Page with Export Options: When user enters data in the online form, the data will be saved to a database. The client can then go to the document generation page, to export the docx files. Upon selecting this option, the mapped document files will be auto-filled using the PHPWord Library. The mapping will happen as per the field names specified.

  • Download and Email options: The client can download and save the generated docx file. Furthermore, there is a form provided to email the docx file as an attachment, upon specifying an email id.

This implementation was provided in a way that met the client’s requirements perfectly. You can of course grow from this idea and customize it, to satisfy your automation requirements.

Ankit Shah

Ankit Shah

3 Responses

  1. I need à simular option, this is what i need, i Want to create à wp website where People can create different resumés. First They register with forms to save all their resumé data , or import data from à existing resumé or linkedin.
    Then They choose à readymade template made by me, different kinds. Where They can see their data in the ready made templates .
    They can download the template in word or PDF , and Pay me for Evert template.
    Where can i Find this information or if you do it what are the costs

Leave a Reply

Your email address will not be published. Required fields are marked *

Get The Latest Updates

Subscribe to our Newsletter

A key to unlock the world of open-source. We promise not to spam your inbox.

Suggested Reads

Join our 55,000+ Subscribers

    The Wisdm Digest delivers all the latest news, and resources from the world of open-source businesses to your inbox.

    Suggested Reads