Free Support Forum - aspose.com

Removing space from mergefield

Hi,

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,
Ravi

Hi

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);

doc.Save(@"out.doc");

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 http://www.aspose.com/Community/Forums/105999/ShowThread.aspx#105999 so please do check it

Thanks,
ravi,

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?

Hi

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);

doc.Save(@"412_105935_raviteja\out.doc");

}

void MailMerge_MergeField_105935(object sender, MergeFieldEventArgs e)

{

e.Text = e.FieldValue.ToString().Trim();

}

Best regards.