MailMergeCleanupParagraphsWithPunctuationMarks Property

Gets or sets a value indicating whether paragraphs with punctuation marks are considered as empty and should be removed if the RemoveEmptyParagraphs option is specified.

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

Syntax

public bool CleanupParagraphsWithPunctuationMarks { get; set; }

Property Value

Type: Boolean

Remarks

The default value is true.

Remarks

Here is the complete list of cleanable punctuation marks:
  • !
  • ,
  • .
  • :
  • ;
  • ?
  • ¡
  • ¿

Examples

Shows how to remove paragraphs with punctuation marks after mail merge operation.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

FieldMergeField mergeFieldOption1 = (FieldMergeField) builder.InsertField("MERGEFIELD", "Option_1");
mergeFieldOption1.FieldName = "Option_1";

// Here is the complete list of cleanable punctuation marks: ! , . : ; ? ¡ ¿
builder.Write(punctuationMark);

FieldMergeField mergeFieldOption2 = (FieldMergeField) builder.InsertField("MERGEFIELD", "Option_2");
mergeFieldOption2.FieldName = "Option_2";

doc.MailMerge.CleanupOptions = MailMergeCleanupOptions.RemoveEmptyParagraphs;
// The default value of the option is true which means that the behavior was changed to mimic MS Word
// We can revert to the old behavior by setting the option to false
doc.MailMerge.CleanupParagraphsWithPunctuationMarks = isCleanupParagraphsWithPunctuationMarks;

doc.MailMerge.Execute(new[] { "Option_1", "Option_2" }, new object[] { null, null });

doc.Save(ArtifactsDir + "MailMerge.RemoveColonBetweenEmptyMergeFields.docx");

See Also