Thanks for your inquiry. In your case, we suggest you please use MailMerge.UseWholeParagraphAsRegion property. Set the value of this property as false as shown below.
This property is used to get or set a value indicating whether whole paragraph with TableStart or TableEnd field or particular range between TableStart and TableEnd fields should be included into mail merge region.
Document doc = new Document(MyDir + "in.docx");
doc.MailMerge.UseWholeParagraphAsRegion = false;
Hi Tahir,
thank you for your answer. That solved one of my two problems
Now the Text is in one line.
But how can i insert Separators? (Text or Char, only between the elements of a Region)
If I fill the MailMergeField.TextAfter with the text “, ” I have a separator at the end, I don’t need:
Text1, Text2, Text3, Text4, Text5,
The output I need is:
Text1, Text2, Text3, Text4, Text5
Thanks for your inquiry. In this case, we suggest you please set the text before field as ", " in your input document. Please implement IFieldMergingCallback interface as shown below to get the desired output.
Document doc = new Document(MyDir + "in.docx");
doc.MailMerge.UseWholeParagraphAsRegion = false;
doc.MailMerge.FieldMergingCallback = new FieldMerging_Callback();
doc.MailMerge.ExecuteWithRegions(......);
doc.Save(MyDir + "18.10.docx");
public class FieldMerging_Callback : IFieldMergingCallback
{
public void FieldMerging(FieldMergingArgs e)
{
if (e.RecordIndex == 0)
e.Field.TextBefore = "";
}
public void ImageFieldMerging(ImageFieldMergingArgs args)
{
}
}