We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Section with mergefield

Hello All,

I don´t know if this is the right place, if not sorry.
I have a problem, if you open the SimpleText.doc, you will see how do i want to show the report, this was made only with text. But when i put a merge field the report won´t behave as the text. The table that i have around the mergefield is to limit the size of this field but when i generate the report the text continuous to grow and doesn´t respect the size define in the properties of the table, instead to break the text in two columns as the report only with simple text.
I am doing something wrong or this is a limitation from aspose/word?

Thank you

Hi Jorge,

Thanks for your inquiry. It seems the issue you are facing is not bug in Aspose.Words issue. Please note that Aspose.Words mimics the same behavior as MS Word does. When you mail merge the AsposeField.docx file using MS Word, text is truncated and table does not expand.

Best Regards,

I have no problem with the text being truncated, my problem is that the text come from the merge field doesn´t continues to the second column as you can see in the simple text.

Hi Jorge,


Thanks for your feedback. I notice a single column in SimpleText.docx and mail merge output of Aspose.Word and MS Word. Please share a screen shot to highlight the second column issue, so we will further look into the requirement and will guide you accordingly.

We are sorry for the inconvenience.

Best Regards,

He Ahmad,


See the images attached.
Hi Jorge,

Thanks for sharing additional information. As stated above, Aspose.Words mimics the same behavior as Microsoft Word does. I am afraid we can not implement the feature in Aspose.Words, as it is not supported in Microsoft Word mail merge feature.

We are sorry for the inconvenience.

Best Regards,

Hi Jorge,


We have further investigated the scenario. To achieve your requirements you can either implement IFeildMergingCallback as following or change the row height of table with mail merge field in your template to “At least” instead of “exactly”. Please note if you change the row height in your template then you do not need to implement IFieldMergingCallback during mail merge process.

Document doc = new
Document(@“Example\AsposeField.docx”);<o:p></o:p>

doc.MailMerge.FieldMergingCallback = new HandleMergeField();

doc.MailMerge.Execute(new string[] { "relevanteClinicalData" },

new object[] { " reasonably big text" });

doc.Save(@"Example\17.4.docx");

------------------

public class HandleMergeField : IFieldMergingCallback

{

void IFieldMergingCallback.FieldMerging(FieldMergingArgs e)

{

if (e.FieldName.Equals("relevanteClinicalData"))

{

Table tbl = (Table)e.Field.Start.GetAncestor(NodeType.Table);

DocumentBuilder builder = new DocumentBuilder(e.Document);

if (builder.MoveToMergeField("relevanteClinicalData"))

{

if (tbl != null)

{

tbl.FirstRow.RowFormat.HeightRule = HeightRule.Auto;

builder.Write(e.FieldValue.ToString());

}

}

}

}

void IFieldMergingCallback.ImageFieldMerging(ImageFieldMergingArgs args)

{

// Do nothing.

}

}


Best Regards,