MailMergeTrimWhitespaces Property

Gets or sets a value indicating whether trailing and leading whitespaces are trimmed from mail merge values.

Namespace:  Aspose.Words.MailMerging
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 22.1.0


public bool TrimWhitespaces { get; set; }

Property Value

Type: Boolean


The default value is true.


Shows how to trim whitespaces from values of a data source while executing a mail merge.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.InsertField("MERGEFIELD myMergeField", null);

doc.MailMerge.TrimWhitespaces = trimWhitespaces;
doc.MailMerge.Execute(new[] { "myMergeField" }, new object[] { "\t hello world! " });

Assert.AreEqual(trimWhitespaces ? "hello world!\f" : "\t hello world! \f", doc.GetText());

ExpandedSee Also