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

Free Support Forum - aspose.com

Removing space from mergefield


when the data is merged to a merged field, is the length of the megefiled fixed?.
Because if the merge field is
and teh data merged is “abc”.
Then in the document i am seeing,

Suppose this is the template.
here is the which is valid.

Then in the document i am seeing,

here is the abc which is valid.
So what to do with that space?.
One more question, when i am inserting document into merge fields, like that if i am doing 2-3 documetns,
then some of the data is not merging properly. The data frm teh Blob frild with html or rtf format is coming as it is, some problem is there, with it.Individually it it sowrkin fine.
Please do tell me what to do for these


Thanks you for your request. I can’t reproduce this problem on my side. Could you please provide me sample code that will allow me to reproduce this problem? I will investigate this and provide you more information.
I used the following code for testing.

Document doc = TestUtil.Open(@"in.doc");
string[] fieldNames = { "test" };
object[] fieldValues = { "abc" };
doc.MailMerge.Execute(fieldNames, fieldValues);

Best regards.

Try to give a long name for the mergefield name and very short name for a mergefield value, give it in teh middle of a paragaraph, that will show you.Also, some code is not merging propoerly when i combine differnet documents, i already posted my code and tempaltes in this thread so please do check it


Also this is what i am getting if i am merging 3 documetns, teh 3rd docuemnt is like this

Note 8: Delivery : 8 weeks after receipt , acceptance of order and advance payment.
Note 9: Export boxing included in this quote.**

Note 10: Inland Freight to Export Crater included in this quote.

The word is not reading these symbols?

I don’t think that a long name of mergefield is a reason of this problem. Maybe this is problem with your data. You can try using the following code to solve this problem.

public void TestMailMerge_105935()
    Document doc = new Document(@"412_105935_raviteja\in.doc");
    string[] fieldNames = { "VeryLongNameOfMergeFieldAndVeryShortValueOfIt" };
    object[] fieldValues = { "abc test " };
    doc.MailMerge.MergeField += new MergeFieldEventHandler(MailMerge_MergeField_105935);
    doc.MailMerge.Execute(fieldNames, fieldValues);
void MailMerge_MergeField_105935(object sender, MergeFieldEventArgs e)
    e.Text = e.FieldValue.ToString().Trim();

Best regards.