Generating Table of Authorities?


#1

Hello,

We are currently evaluating Aspose.Word for a project at our company. One of our main requirements is to be able to generate a Table of Authorities and insert this into a user’s document.

I perused the documentation and I noticed that a Table of Contents can be created, but nothing for Table of Authorities.

Is there a way this can be done using Aspose.Word?

Thanks in advance.
-Mike Z.


#2

The Table of Authorities is a field and can be inserted using DocumentBuilder.InsertField method.

Fields in MS Word documents consist of a field code and a field result. The field code is like a formula and the field result is like the value that the formula produces. The field code may also contain field switches that are like additional instructions to perform a specific action.

You can switch between displaying field codes and results in your document in MS Word using the keyboard shortcut Alt+F9. Field codes appear between curly braces ( { } ).

To create fields using InsertField, you need to specify a field type, field code and field value. If you are not sure about particular field code syntax, create the field in MS Word first and switch to see its field code.

Here is an example of how to insert TOA and TA fields:

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

// inserting TOA field

builder.InsertField(@"TOA \h \c ""1"" \p", "");

builder.Writeln();

// inserting TA field

builder.InsertField(@"TA \l ""Text"" \s ""Text"" \c 1", "");

Please mind that these fields are not calculated in Aspose.Words and are not automatically updated by MS Word. To see get the actual values for TOA fields you need to update them in MS Word via field context menu or by pressing F9.

Best regards,