简体   繁体   English

如何通过Apache Poi更新docx文件的目录(TOC)

[英]How to update table of content (TOC) for docx file by apache poi

How to update table of contents (TOC) and then convert docx file to pdf? 如何更新目录(TOC),然后将docx文件转换为pdf? I want to create and update table of content in docx file and then convert it to pdf, so I want this TOC to be updated in pdf file. 我想在docx文件中创建和更新目录,然后将其转换为pdf,所以我希望此TOC在pdf文件中进行更新。

This code update TOC after opening docx file by user and I don't need it. 这段代码由用户打开docx文件后更新目录,我不需要它。

docx.enforceUpdateFields();

I want TOC to be updated automatically by my program. 我希望目录可以由我的程序自动更新。 Thanks. 谢谢。

Based on comment in this link , I found out that there is no way to update TOC automatically. 根据此链接中的评论,我发现无法自动更新TOC。 Ben said on that comment " It then relies on a user to open the document in Word to generate the actual table of contents. Unfortunately, Word can't be made to update the TOC automatically and without user interaction ". Ben在评论中说:“ 然后它依靠用户在Word中打开文档来生成实际的目录。不幸的是,不能在没有用户交互的情况下使Word自动更新TOC ”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM