I want to add table of contents(toc) on 3rd page of Doc using apache XWPF.
Here is the code below :
XWPFDocument doc = new XWPFDocument();
CTSdtBlock block = doc.getDocument().getBody().addNewSdt();
TOC toc = new TOC(block);
toc.addRow(3, "toc", 3, "16283778");
doc.write(new FileOutputStream(new File("toc.docx")));