OPTIMIZE DOCUMENT AUTOMATION

Performance Guidelines

Version: 1.0
Valid From: 01.06.2025

Table of Contents

  1. Performance Considerations
  2. Generic dox42 Optimization
    1. Try to avoid too many nested data sources in a loop
    2. Try to load dependent data in one call
    3. Use look-up function of dox42
    4. Moving conditions in big templates to dynamic fields
    5. Analyzing data load performance
    6. Using bulk letter to optimize large repetitive documents
    7. DocGen datasource as a tool to outsource large content
    8. Generated documents with large file sizes

1 Performance Considerations

dox42 allows for very fast document generation in general. Normally you don’t need to worry about performance. However, there are scenarios that can impact docgen performance and require additional optimization.

Examples:

  1. Templates importing large amounts of data (e.g., collective invoice with > 500 positions)
  2. Looking up additional data for each position
  3. Templates containing many automated ranges – especially combined with large datasets
  4. Templates importing many additional documents from SharePoint (e.g., large contracts)

In these scenarios, plan additional optimization effort. This document provides best practices and tips.

2 Generic dox42 Optimization

2.1 Try to avoid too many nested data sources in a loop

Example: A collective invoice with 500 positions. For each position you load:

  • Product image from SharePoint
  • Description from SharePoint
  • Data from Dynamics

This results in 1000+ SharePoint downloads and 500 Dynamics calls in one generation process. Such high request volume may trigger Microsoft throttling and stall performance.

2.2 Try to load dependent data in one call

Extend the data provider (e.g., Dynamics report) to include dependent data. This eliminates hundreds of look-up calls. For Dynamics CE, use FetchXML.

2.3 Use look-up function of dox42

Load all dependent data in one call (e.g., all product descriptions). Use the look-up function in the data map (available since version 5) to establish dependencies.

The look-up is then performed in memory, avoiding additional loads.

2.4 Moving conditions in big templates to dynamic fields

In very large templates with many datasets or tables, replacing non-looping conditional automate ranges with dynamic fields can improve performance.

Automate ranges usually do not noticeably impact performance. However, when processed across many iterations, performance can improve by replacing simple conditional show/hide ranges with dynamic fields.

Example scenario:

A large table contains contact information. Additional notes should appear if a contact preordered a ticket.

Instead of a conditional automate range, use a dynamic field with logic like:

If condition Then
    result = "Additional note"
Else
    result = ""
End If

This produces the same output with better performance when processing large datasets.

2.5 Analyzing data load performance

Create a TRACE log (available since Version 5 in the Add-In).

Steps:

  1. Copy the log into Excel
  2. Use Data > Text to Columns
  3. Separator = |
  4. Insert Pivot Table

This allows analyzing:

  • Total load time
  • Number of loads

2.6 Using bulk letter to optimize large repetitive documents

For large repetitive documents (e.g., yearly reports, printer output), use the bulk letter functionality.

With dynamic naming, a separate file is created per dataset loop.

Files can be processed via printer drop folder.

If merging is required:

  1. Create a second template
  2. Use Excel datasource to initialize naming data fields
  3. Process file names in a dynamic field

Using a loop with datafield type PDFAttachment results in a merged document.

For DOCX merging, use datafield type WordDoc. PDFAttachment is inserted only when output format is PDF.

2.7 DocGen datasource as a tool to outsource large content

Since version 5, the DocGen datasource allows creating sub-templates integrated into the main document.

If large content (e.g., complex tables) must be shown or hidden based on conditions, move it into sub-templates.

Hidden sub-templates are not calculated in the background, improving performance.

2.8 Generated documents with large file sizes

Inserting high-quality images or PDFs increases file size and slows download speed. This mainly affects graphically advanced documents.

Optimization for PDFs:

  • Using datafield type PDF inserts the PDF as an image
  • Using datafield type PDFAttachment appends the PDF to the end of the document

Since images are larger than appended PDFs, using PDFAttachment can significantly reduce file size.