''
'' This code is part of Document Solutions for Word demos.
'' Copyright (c) MESCIUS inc. All rights reserved.
''
Imports System.Globalization
Imports GrapeCity.Documents.Word
Imports GrapeCity.Documents.Word.Fields
Imports GrapeCity.Documents.Word.Layout
'' This sample shows how to use the TOA and TA field options
'' to add a TOA (Table of Authorities) field to a DOCX Word document.
Public Class ToaFieldOpts
Function CreateDocx() As GcWordDocument
Dim cits As (String, String)() = {
("Alejado v. City & Cty. of Honolulu", "89 Hawai'i 221, 971 P.2d 310 (App. 1998)"),
("Anderson v. United States", "612 F.2d 1112 (9th Cir.1980)"),
("Asato v. Procurement Policy Bd.", "132 Hawai'i 333, 322 P.3d 228 (2014)"),
("Awakuni v. Awana", "115 Hawai'i 126, 165 P.3d 1027 (2007)"),
("Baker v. Carr", "369 U.S. (1962)")
}
Dim doc = New GcWordDocument()
Dim ta = New TaFieldOptions(doc) With {
.Category = 1
}
Dim rand = Util.NewRandom()
Dim i As Integer = 0
Do While i < rand.Next(10, 20)
Dim p = doc.Body.AddParagraph(Util.LoremIpsumPar())
Dim cit = cits(rand.Next(0, cits.Length - 1))
p.AddRun("See case " & cit.Item1 & ".")
ta.LongCitation.Text = cit.Item1 & "," & vbLf & cit.Item2
p.AddComplexField(ta)
i += 1
Loop
Dim toa = New ToaFieldOptions(doc) With {
.EntriesCategory = 1
}
doc.Body.AddParagraph("TABLE OF AUTHORITIES")
Dim field = doc.Body.AddParagraph().AddComplexField(toa)
field.Update(New WordLayoutSettings() With {
.FontCollection = Util.FontCollection,
.Culture = CultureInfo.GetCultureInfo("en-US")
})
Return doc
End Function
End Class