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

Free Support Forum - aspose.com

Remove the Merge Field

Hi ,

How can i remove a merge field ?

I have mergefield called <FirstName> with bunch of other merge fields.

But i want to remove only FirstName out of the document .

Please let me know ,how is it possible to do it.

Thanks,
Jaswanth

Hi Jaswanth,

Thanks for your inquiry. Please use the Field.Remove method to remove the field from the document.

Another way to remove the mail merge field is to call DocumentBuilder.MoveToMergeField Method (String). This method moves the cursor to a position just beyond the specified merge field and removes the merge field.

Document doc = new Document(MyDir + "in.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToMergeField("FirstName");