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: 21.5.0

ExpandedSyntax

public bool TrimWhitespaces { get; set; }

Property Value

Type: Boolean

ExpandedRemarks

The default value is true.

ExpandedExamples

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