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

Free Support Forum - aspose.com

Manually creating fields


I’d like to be able to create fields without using the InsertField member of the DocumentBuilder. The main reason for not wanting to use InsertField() is that it seems to ignore newline characters; but there are other minor reasons as well.

However, I seem to be hitting a problem directly - FieldStart, FieldSeparator and FieldEnd have no documented constructor. Whilst there is one that takes 4 arguments, some of these arguments seem to be mangled symbols indicating that I’m probably not supposed to be doing what I’m trying to do? Are there any examples for creating fields that do not use the DocumentBuilder?


Hi Mark,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. There is no way to insert fields without DocumentBuilder. Could you please provide me code example, which works improperly for you? In addition, it would be great if you attach the expected result. I will check the problem and provide you more information or solution of the problem.

Best regards.


I actually eventually found a way around the problem. I am using DocumentBuilder.InsertField( fieldcode, "") to create the field but with empty text and then use the builder.MoveTo( field.Separator.NextNode ) to position the cursor so that I can then use builder.Write() functions to populate the field how I want before finally calling builder.MoveToDocumentEnd() to return the cursor to the right place. By doings this I get newlines being respected, and arbitrary formatting of the field content as a bonus (such as bold, italics, fontname, fontsize, etc). This seems to work fine, and I can't think of any problems with it.

Best regards,

Sorry, I meant field.Separator.NextSibling naturally.

Hi Mark,

It's great you found what you were looking for.

If you have any further queries please feel free to ask us.