Adding table of contents (TOC) to our document is a useful way to show readers what chapters are included in our document. When readers click on the table of contents, they can quickly navigate to the specific parts that they’re interested. In this blog, I will introduce how to add table of contents (TOC) to a PDF document programmatically in Java using Free Spire.PDF for Java library. import com.spire.pdf.*; import com.spire.pdf.actions.PdfGoToAction; import com.spire.pdf.annotations.*; import com.spire.pdf.general.PdfDestination; import com.spire.pdf.graphics.*; import java.awt.*; import java.awt.geom.*; public class TableOfContent { public static void main(String[] args) throws Exception { //load PDF document PdfDocument doc = new PdfDocument( "sample.pdf" ); int pageCount = doc.getPages().ge...
A blog about Microsoft Office and PDF document development using .NET and Java.