Free Support Forum - aspose.com

Using FieldStart and InsertField

Hi,

I am trying to try the code snippet defined in the following thread :

http://www.aspose.com/community/forums/permalink/202127/202127/showthread.aspx#202127

Apparently this line is throwing the exception when it's compiled ('Cannot implicitly convert type... ')

FieldStart start = builder.InsertField("IF \"", null);

May i know what is the correct way of using InsertField method ?

Regards,

hadi teo

Hi,

May i know what is the correct way of using nested field update ? such as this " Nested fields IF { =OR({ COMPARE { =2.5 +PRODUCT(3,5 ,8.4) } > 4}, { =2/2 }) } = 1 "Credit not acceptable" "Credit acceptable"
" http://www.aspose.com/docs/display/wordsnet/About+Field+Update

Regards,

hadi teo

Hi Hadi,


Thank for your inquiry. You can use the code like below to insert fields nested with an IF field.

Document doc = new Document();<o:p></o:p>

DocumentBuilder builder = new DocumentBuilder(doc);<o:p></o:p>

<o:p> </o:p>

// Insert a few page breaks (just for testing)<o:p></o:p>

for (int i = 0; i < 5; i++)<o:p></o:p>

builder.InsertBreak(BreakType.PageBreak);<o:p></o:p>

<o:p> </o:p>

// Move the DocumentBuilder cursor into the primary footer.<o:p></o:p>

builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);<o:p></o:p>

<o:p> </o:p>

// We want to insert a field like this:<o:p></o:p>

// { IF {PAGE} <> {NUMPAGES} “See Next Page” “Last Page” }<o:p></o:p>

Field field = builder.InsertField(@"IF “);<o:p></o:p>

builder.MoveTo(field.Separator);<o:p></o:p>

builder.InsertField(“PAGE”);<o:p></o:p>

builder.Write(” <> “);<o:p></o:p>

builder.InsertField(“NUMPAGES”);<o:p></o:p>

builder.Write(” “See Next Page” “Last Page” ");<o:p></o:p>

<o:p> </o:p>

// Finally update the outer field to recalcaluate the final value. Doing this will automatically update<o:p></o:p>

// the inner fields at the same time.<o:p></o:p>

field.Update();