Project reports, product manuals, technical documents, and other long-form Word files often contain multiple chapters and sections. As the content changes, section titles, chapter order, and page numbers may also change. Maintaining the table of contents manually is repetitive and can easily result in missing headings or incorrect page numbers. A Word table of contents is a field generated from the heading styles used in the document. As long as the document uses Heading 1, Heading 2, Heading 3, and other built-in heading styles correctly, the table of contents can be inserted programmatically and updated after the document changes. This article demonstrates how to use Java to: Create a Word document with multilevel headings Generate a table of contents from Heading 1 through Heading 3 Insert a table of contents into an existing Word document Update heading text and page numbers in an existing table of contents Control which heading levels appear in the table of contents How Word Ident...
A blog about Microsoft Office and PDF document development using .NET and Java.