【发布时间】:2020-11-13 12:32:35
【问题描述】:
我将 OpenXML SDK v2.11.3 与 .net core 3.1 一起使用,当我尝试从 word 文档中获取总页数时,有时它会返回空值。
using (var document = WordprocessingDocument.Open(memoryStream, true))
{
var pages = Convert.ToInt32(document.ExtendedFilePropertiesPart.Properties.Pages.Text);
}
System.NullReferenceException: '对象引用未设置为 一个对象的实例。 DocumentFormat.OpenXml.ExtendedProperties.Properties.Pages.get 返回 null。
从 docx 文件中获取总页数的最佳方法是什么?
【问题讨论】:
标签: c# xml openxml docx openxml-sdk