Create Word Templates For Document Automation Using PDF

Document template is a blueprint word document. It’s a guide for creating word documents using user supplied data.

The WordPress Document Automation and WordPress Document Automation Pro plugins use them as input.

These plugins extract the input meta information from document templates. A form to capture user input is built using this meta. To create a document template we need the following

  • Install Libre Office – This is an office suite like Microsoft Office to create the document template. It’s free to use.
    • We use .fodt word document from Libre Office as document template.
    • .fodt file store data in XML format.
  • A tool that converts pdf file to image(s). We use image as background for each page of the document template. Here are the options

Watch the video at the top to see the process in action.

To convert a pdf file to a document template, we should

Extract images from pdf and set them as background to the template

  1. Extract images from pdf file – Use of the tools mentioned above to create images from your pdf file.
  2. Create a blank document template
    • Open Libre Office and create a blank Libre Writer document.
    • Save the file with a .fodt extension.
  3. Set the extracted images as background to each page of the template
    • Select a blank page on the document template.
    • Goto Format > Page from the top menu.
    • Select the Area tab
    • On the Area page, click on the Bitmap button.
    • Click on Add/Import button and upload one of the extract image.
    • In the Options area, select Stretched from the Style drop-down menu.
    • The image is now background to the page.
  4. Remove the excess margins
    • Image background image doesn’t cover the page. It’s due to margins set on the page.
    • Click on the Page tab next to the Area mentioned above.
    • Set all the margin values to zero on this page and apply changes
    • Now your page is setup

If your pdf document has more than one page, follow the steps 3 to 4 for each image. At the end each image will have it’s own page in the document template.

Add textboxes on the page where we need data.

A textbox is like a text field found on a web form. It’s placeholder for text got via form.

Our plugin reads the textbox information from the document template and creates a form with a single click.

Data provided by user’s form submission, populates the textbox. That’s how the plugin creates the final documents.

To add a textbox

  1. On the top menu goto to Insert and click on Text Box.
  2. The cursor changes to a cross-hair. This indicates we need to select an (rectangle) area for the textbox. User data shows on this textbox.
  3. You can drag the textbox.
  4. Add a placeholder text in textbox that uniquely identifies it.
  5. If the document template needs the same data at more than one place, ensure you us the same unique placeholder text at those places.

Repeat the above steps for all the places on the document that needs user input.

Once you add all the textboxes, the document template is ready.