title: How to create table of content in Word Document using Apache POI?
body: <p>We are creating word document using apache POI. I have pasted code snippet below:</p>
  
  <pre><code>XWPFDocument doc = new XWPFDocument();
  XWPFParagraph p1 = doc.createParagraph();
  p1.setAlignment(ParagraphAlignment.CENTER);
  p1.setBorderBottom(Borders.DOUBLE);
  p1.setBorderTop(Borders.DOUBLE);
  p1.setBorderRight(Borders.DOUBLE);
  p1.setBorderLeft(Borders.DOUBLE);
  p1.setBorderBetween(Borders.SINGLE);
  p1.setVerticalAlignment(TextAlignment.TOP);
  
  XWPFRun r1 = p1.createRun();
  r1.setBold(true);
  r1.setText("The quick brown fox");
  r1.setBold(true);
  r1.setFontFamily("Courier");
  r1.setUnderline(UnderlinePatterns.DOT_DOT_DASH);
  r1.setTextPosition(100);
  </code></pre>
  
  <p>But our requirement is create table of content with page number.
  Please provide me information how to create table of content....</p>