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

Free Support Forum - aspose.com

Inserting a field without using DocumentBuilder

Hi,

I need to insert a page number field in a document, and I'm trying to perform this without using the DocumentBuilder.

Accessing it by nodes would be a lot more compliant with the existing base I'm working on, but I'm not finding any way to obtain an instantiated object of the Field class.

Thank you.

Dodo

Hi

Thanks for your request. Unfortunately, there is no way to create field without using DocumentBuilder. Field in MS Word document is not a single node, it consist of few nodes. Here is structure of field in MS Word:

[FieldStart][one or few Run nodes(field code)][FieldSeparator][one or few Run nodes(field value)][FieldEnd].

So in case of creating a field from scratch you would need to create at least five nodes. That is why creating of fields is wrapped into DocumentBuilder.InsertField method that creates all required nodes for you.

Best regards,