Add bookmarks on PDF File
  Document document = new Document(PageSize.A4, 50, 50, 25, 25);
 
            // Create a new PdfWriter object, specifying the output stream
          
            PdfWriter.GetInstance(document, new FileStream(Server.MapPath(“MyFirstPDF.pdf”), FileMode.Create));
 
            Chapter chapter1 = new Chapter(new Paragraph(“This is Chapter 1”), 1);
            Section section1 = chapter1.AddSection(20f, “Section 1.1”, 2);
            Section section2 = chapter1.AddSection(20f, “Section 1.2”, 2);
            Section subsection1 = section2.AddSection(20f, “Subsection 1.2.1”, 3);
            Section subsection2 = section2.AddSection(20f, “Subsection 1.2.2”, 3);
            Section subsubsection = subsection2.AddSection(20f, “Sub Subsection 1.2.2.1”, 4);
            Chapter chapter2 = new Chapter(new Paragraph(“This is Chapter 2”), 1);
            Section section3 = chapter2.AddSection(“Section 2.1”, 2);
            Section subsection3 = section3.AddSection(“Subsection 2.1.1”, 3);
            Section section4 = chapter2.AddSection(“Section 2.2”, 2);
            chapter1.BookmarkTitle = “Changed Title”;
            chapter1.BookmarkOpen = true;
            chapter2.BookmarkOpen = true;
            document.Add(chapter1);
            document.Add(chapter2);
            // Add the Paragraph object to the doc
Advertisements