DocumentAssembler class

DocumentAssembler class

Provides routines to populate template documents with data and a set of settings to control these routines.

The DocumentAssembler type exposes the following members:

Constructors

Constructor Description
init Initializes a new instance of this class.

Methods

Method Description
assemble_document Loads a template document from the specified source path, populates the template document with data from the specified single or multiple sources, and stores the result document to the target path using default LoadSaveOptions.
assemble_document Loads a template document from the specified source path, populates it with data from the given sources, and saves the result to the target path using the provided LoadSaveOptions.
assemble_document Loads a template document from the specified source stream, populates it with data from the given sources, and writes the result to the target stream using default LoadSaveOptions.
assemble_document Loads a template document from the specified source stream, populates it with data from the given sources, and writes the result to the target stream using the provided LoadSaveOptions.

Properties

Property Description
barcode_settings The set of settings controlling barcode generation while assembling a document.
known_types The unordered set of unique type names that can be referenced in document templates processed by this assembler instance to invoke static members, perform type casts, etc.
options The options property defines a set of flags that control the behavior of this DocumentAssembler instance while assembling a document.

Fields

Field Description
USE_REFLECTION_OPTIMIZATION Gets or sets a value indicating whether invocations of custom type members performed via reflection API are optimized using dynamic class generation or not. The default value is true.

Example

from groupdocs.assembly import DataSourceInfo, DocumentAssembler

orders = [
    {"Number": 10001, "Product": "Harbor Blend whole bean coffee", "Quantity": 30, "Price": 552.0},
    {"Number": 10004, "Product": "Aged harbour cheddar", "Quantity": 8, "Price": 132.0},
]

# Each data source goes under the name the template's tags use for it
assembler = DocumentAssembler()
assembler.assemble_document("order-table.docx", "order-table-report.docx", [
    DataSourceInfo("Quayside Bistro", "customer"),
    DataSourceInfo(orders, "orders"),
])

Guides

Task guides that use DocumentAssembler:

See Also