更新域
Document doc = new Document("模板路径");
doc.UpdateFields(); //更新域,会更新样式
只更新页码
Document doc = new Document("模板路径");
foreach (Field field in doc.Range.Fields)
{
if (field.Type == FieldType.FieldTOC)
{
FieldToc toc = (FieldToc)field;
toc.UpdatePageNumbers(); //定位toc只更新页码
}
else
{
field.Update();
}
}