Repeat Paragraphs and Sections

A document consists of data or information in different formats. Text, images, graphs, hyperlinks, and so on. Text contents are often generated in Paragraphs. Using PDF4me you can generate multiple paragraphs while populating a document.

Let us look at an example template syntax for top-rated mobile apps-

<<foreach [app in applications]>><<[app.listAppName]>> in <<[app.listAppType]>> platform is a <<[app.category]>> app and has a <<[app.AppRating]>> rating.
<</foreach>>

The data for the particular template will be in the following JSON Syntax -

{
  "surveyName": "Top-rated Apps",
  "applications": [
  {
    "listAppName": "Instagram",
    "listAppType": "iOS",
    "category": "Social Media",
    "AppRating": "4.9"
  },
  {
    "listAppName": "Whatsapp",
    "listAppType": "iOS",
    "category": "Chat",
    "AppRating": "4.8"
  },
  {
    "listAppName": "Player UG",
    "listAppType": "Android",
    "category": "Gaming",
    "AppRating": "4.75"
  }
 ]
}

If there is no data in the app list, this will throw a null exception. This can be avoided by checking for null arrays. This can be enabled by using Any() method.

The above syntax can be re-written with the Any() method -

<<if [members.Any()]>>
<<foreach [app in applications]>><<[app.listAppName]>> in <<[app.listAppType]>> platform is a <<[app.category]>> app and has a <<[app.AppRating]>> rating.
<</foreach>>
No Apps listed
<< /if >>