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

Free Support Forum - aspose.com

Nested fields

Hi, there is a example of fields that I want to reproduct in a picture in attachment. It’s from DocumentExplorer.

Outer field is FIELD_FORMULA, and inner field is FIELD_PAGE. Is there any way to do this.

There id example document in attachment too. It’s in footer of the pages.

Thanks.

Hi

Thanks for your inquiry. I think that you should use code like the following.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

//insert first field

FieldStart start = builder.InsertField("IF = 0 \"test\" \"\" \\* MERGEFORMAT ", "");

//create run with part of first field code

Run run = new Run(doc);

run.Text = "IF";

//insert run into the field

builder.CurrentParagraph.InsertAfter(run, start);

//remove part of field code from inserted field

(run.NextSibling as Run).Text = (run.NextSibling as Run).Text.Replace("IF", "");

builder.MoveTo(run.NextSibling);

builder.Write(" ");

//insert nested field

builder.InsertField("MERGEFIELD test \\* MERGEFORMAT", "");

doc.Save(@"345_101817_ivica.v\out.doc");

I hope that this code will help you to solve your task.

Best regards.