![](/img/trans.png)
[英]Wrong values trying to get words count from a Microsoft Word document with OpenXML?
[英]Can't get the pages count from a word document with OpenXml
我將 OpenXML SDK v2.11.3 與 .net 核心 3.1 一起使用,當我嘗試從 word 文檔獲取總頁數時,有時它會返回 null 值。
using (var document = WordprocessingDocument.Open(memoryStream, true))
{
var pages = Convert.ToInt32(document.ExtendedFilePropertiesPart.Properties.Pages.Text);
}
System.NullReferenceException:“對象引用未設置為 object 的實例。” DocumentFormat.OpenXml.ExtendedProperties.Properties.Pages.get 返回 null。
從 docx 文件中獲取總頁數的最佳方法是什么?
自從
您不一定能從任意 DOCX 文件中獲取頁數。
有關更多詳細信息和一些有限的解決方法,請參閱如何按頁碼訪問 OpenXML 內容?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.