Changing Background Color Dynamically

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Assembly MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-assembly -- dnx GroupDocs.Assembly.Mcp --yes
Folders, licensing and more →

You can set text background color for document contents dynamically using backColor tags.

The Code

Note
The example reads the shop data described in The Business Layer.
import json

from groupdocs.assembly import DataSourceInfo, DocumentAssembler

with open("orders.json", encoding="utf-8") as f:
    orders = json.load(f)

assembler = DocumentAssembler()
assembler.assemble_document("background-color.docx", "background-color-report.docx", [
    DataSourceInfo(orders, "orders"),
    DataSourceInfo("Coral", "color"),
])

The following sample file is used in this example: background-color.docx

The following sample file is used in this example: orders.json

Binary file (DOCX, 11 KB)

Download full output

Download