Tutorial: How to Work with Lists in GroupDocs.Assembly Cloud
Overview
In this tutorial, you’ll learn how to work with lists in GroupDocs.Assembly Cloud, creating dynamic document templates that can generate various types of lists. Lists are fundamental elements in documents that help organize information in a readable and structured format.
Learning Objectives
By the end of this tutorial, you will be able to:
- Create in-paragraph lists for embedding items within text
- Generate dynamic bulleted lists with custom formatting
- Implement numbered lists with automatic numbering
- Control nested list numbering with restart features
- Apply conditional formatting to list items
- Create multi-level lists with custom styling
Prerequisites
Before starting this tutorial, you should have:
- A GroupDocs.Assembly Cloud account (sign up for a free trial)
- Basic understanding of template syntax and data bands
- Familiarity with JSON or XML data sources
- Your development environment set up (any language with the GroupDocs.Assembly Cloud SDK installed)
Understanding List Types in Document Templates
Documents support several list types, each with distinct visual presentations and use cases:
- In-paragraph lists - Items embedded within paragraph text
- Bulleted lists - Items preceded by bullet symbols (•, ◦, ■, etc.)
- Numbered lists - Items with sequential numbers or letters
- Multi-level lists - Nested lists with hierarchical structure
Let’s explore how to implement each type using GroupDocs.Assembly Cloud templates.
Sample Data Source
Throughout this tutorial, we’ll use a sample product catalog as our data source:
XML Data Source
JSON Data Source
Creating an In-Paragraph List
In-paragraph lists embed items within continuous text, using separators like commas or semicolons.
Template Syntax
We provide support for the following products: <<foreach [in products]>><<[IndexOf() != 0 ? ", " : ""]>><<[ProductName]>><</foreach>>.
Result
We provide support for the following products: LG Nexus 5, Nokia Lumia 5801, Huawie Mate S, Moto Style.
How It Works
- The
foreach
tag iterates through all products in the data source - The
IndexOf()
method determines if it’s the first item (index 0) - For non-first items, a comma and space are added before the product name
- Each product name is inserted using the
<<[ProductName]>>
expression
Try it yourself
Create a simple template with an in-paragraph list of your own data. Try using different separators like semicolons or custom text.
Generating a Bulleted List
Bulleted lists use symbols to visually separate items in a vertical list.
Template Syntax
• <<foreach [in products]>><<[ProductName]>>
<</foreach>>
Result
• LG Nexus 5
• Nokia Lumia 5801
• Huawie Mate S
• Moto Style
How It Works
- The bullet character (•) is placed at the beginning of the template line
- The
foreach
tag iterates through all products - Each product name is placed on a new line with the bullet inheriting from the template
Try it yourself
Create a bulleted list with different bullet symbols:
- Use standard bullets (•)
- Try squares (■) or other Unicode symbols
- Apply custom indentation to your list
Implementing a Numbered List
Numbered lists automatically assign sequential numbers to items.
Template Syntax
1. <<foreach [in products]>><<[ProductName]>>
<</foreach>>
Result
1. LG Nexus 5
2. Nokia Lumia 5801
3. Huawie Mate S
4. Moto Style
How It Works
- Start with a numbered item in your template (1.)
- The
foreach
tag iterates through the products - Document processors automatically continue the numbering sequence
C# SDK Implementation Example
Python SDK Implementation Example
Working with Nested Lists and Numbering Restart
When working with nested lists, you may need to restart numbering for each outer list item.
Template Syntax
<<foreach [order in Orders]>><<[order.ClientName]>><<[order.ClientAddress]>>
1. <<restartNum>><<foreach [service in order.Services]>><<[service.Name]>>
<</foreach>><</foreach>>
How It Works
- The outer
foreach
loop iterates through orders - For each order, client information is displayed
- The
<<restartNum>>
tag ensures numbering starts from 1 for each order’s services - The inner
foreach
loop then lists all services with fresh numbering
Try it yourself
Create a template with nested list structures that use the restartNum
tag to control numbering behavior.
Applying Conditional Formatting to List Items
You can dynamically apply different formatting to list items based on conditions.
Template Syntax
We provide support for the following products:
1. <<foreach [in products]>><<if [IndexOf() % 2 == 1]>><span style="background-color:#ffa69e;color:#000;"><<[ProductName]>></span>
2. <<else>><span style="background-color:#b8f2e6;color:#000;"><<[ProductName]>></span><<</if>><</foreach>>
Result
This would produce a list with alternating background colors:
- Odd items have a pink background
- Even items have a teal background
How It Works
- The
foreach
tag iterates through all products - The
if
condition checks if the item index modulo 2 equals 1 (odd index) - Different style spans are applied based on the condition
- The product name is displayed with the appropriate styling
REST API Implementation with cURL
Advanced List Techniques
Creating Custom-Formatted Multi-Level Lists
Combining Lists with Tables
Lists can be combined with tables to create structured document layouts:
Troubleshooting Common Issues
When working with lists in templates, you might encounter these common issues:
- Incorrect list indentation - Ensure proper nesting levels in your template
- Numbering sequence errors - Check for proper use of the
restartNum
tag - Formatting inconsistencies - Verify that your conditional formatting is properly closed
- Paragraph break problems - Pay attention to paragraph breaks in your templates
Tip: Always test your templates with small data sets first, then scale up to your complete data source.
What You’ve Learned
In this tutorial, you’ve learned how to:
- Create different types of lists (in-paragraph, bulleted, numbered)
- Control list numbering with the
restartNum
tag - Apply conditional formatting to list items
- Implement advanced list techniques for complex documents
Further Practice
To reinforce your learning, try these exercises:
- Create a multi-level list that shows product categories and their items
- Implement a numbered list with custom number formatting (Roman numerals or letters)
- Build a conditionally formatted list that highlights special items based on price or inventory