Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# novacode docx查找页码_C#_Docx_Page Numbering_Novacode Docx - Fatal编程技术网

C# novacode docx查找页码

C# novacode docx查找页码,c#,docx,page-numbering,novacode-docx,C#,Docx,Page Numbering,Novacode Docx,我正在使用Novacode DocX生成C#中的Word(DocX)文档。 在代码中的某个地方,我有一个对段落对象的引用,我想知道该段落在哪一页上。不幸的是,没有Pargraph.PageNumber选项或类似的选项 是否有解决方法?要生成内容表,可以使用以下代码: DocX myDocument = DocX.Load(FilePath); TableOfContents ToC = fullReportDocument.InsertTableOfContents( titl

我正在使用Novacode DocX生成C#中的Word(DocX)文档。 在代码中的某个地方,我有一个对段落对象的引用,我想知道该段落在哪一页上。不幸的是,没有Pargraph.PageNumber选项或类似的选项


是否有解决方法?

要生成内容表,可以使用以下代码:

DocX myDocument = DocX.Load(FilePath);

TableOfContents ToC = fullReportDocument.InsertTableOfContents(
        title : "Your Title",
        switches : TableOfContentsSwitches.O | TableOfContentsSwitches.H | TableOfContentsSwitches.Z | TableOfContentsSwitches.U,
        headerStyle : null,
        maxIncludeLevel : 2
);

maxIncludeLevel可能是您想要的参数

我认为这是不可能的,因为docx文档中不包含分页信息,只有在呈现docx时才能计算它,我认为Novacode不知道如何呈现docx。我明白您的意思,感谢您的回复。现在我想出了一种方法来模拟相同的行为,使用目录(因为它使用占位符作为页码)。但是,当我编辑文档时,ToC不会自动更新。您知道是否可以使用Novacode DocX强制更新ToC,或者仅使用特定的头级别生成新的ToC?