IF-ELSE Statements - PDF and Word Documents

With conditional statements, you can set- if some condition is applicable, then do something.  Non-IT users can add conditional sections right inside the Word and PDF templates and this doesn't require programming skills.

Let's take the scenario of a loan agreement. If the number of borrowers = 1, then the loan agreement should show only one borrower name and a signature section. If the number of borrowers = 2, then the loan agreement should show both the borrower names and respective signature sections. This is where if-else conditions come handy. Instead of maintaining different templates, you can have a single template with conditional statements. They show/hide data based on the input to produce the right document

Creating conditional statements in EDocGen is very easy. Just add relevant tags in the template

This article details creating a  template with conditional fields.  They determine the pieces of information that should be pulled into your document or information that should be displayed.

Let's examine the below template with two text fields.


Simple conditions:

Let's start with a simple condition. If the name is "Steve", we want to show him a message.

{#Enter_Name == "Steve"}
      We're thrilled to have you here.

Notice that the if condition starts with {# and ends with {/}.   In your JSON/XML/Excel, if the value for Enter_Name field is Steve, then this message would be displayed. Simple right! 

Let's say you want to show the telephone number in your documents - only if it's available. This is the condition for checking Boolean.


Use Boolean checking for hiding blanks and empty lines. Ex: If Address value is available, display that. Else show something else.

Compound conditions

EDocGen supports  AND (&&), OR (||). You can create extremely complex conditional statements using them.

{#Enter_Telephone !="" &&  Enter_Name !=""}
   Do something

Similarly you can also use  parenthesis  (condition1 && condition 2) || condition 3)

{(#Enter_Telephone =="1234" &&  Enter_Name !="") ||(#Enter_Telephone =="4567" &&  Enter_Name =="Steve")}
    Do something


For table population, the systems loops over JSON /XML/Excel data to populate the rows. So write your conditions right inside the columns. This way you can show/hide a particular row.

Content Blocks

The population of content blocks using if-else conditions is extremely useful for populating product specific sub-templates and content.