Blog

 
1:   using System;
2:   using System.IO;
3:  
4:   using iTextSharp.text;
5:   using iTextSharp.text.pdf;
6:  
7:   namespace iTextSharp.tutorial.Chap11
8:   {
9:       public class Chap1109 
10:       {
11:       
12:           public Chap1109() 
13:           {
14:           
15:               Console.WriteLine("Chapter 11 example 9: outlines with actions");
16:           
17:               // step 1: creation of a document-object
18:               Document document new Document(PageSize.A450505050);
19:           
20:               try 
21:               {
22:                   // step 2:
23:                   // we create a writer that listens to the document
24:                   PdfWriter writer PdfWriter.GetInstance(documentnew FileStream("Chap1109.pdf"FileMode.Create));
25:                   // step 3: we open the document
26:                   document.Open();
27:                   // step 4:
28:                   // we add some content
29:                   document.Add(new Paragraph("Outline action example"));
30:                   // we add the outline
31:                   PdfContentByte cb writer.DirectContent;
32:                   cb.AddOutline(new PdfOutline(cb.RootOutlinenew PdfAction("http://www.Geocities.Com/itextpdf"), "http://www.Geocities.Com/itextpdf"));
33:                   cb.AddOutline(new PdfOutline(cb.RootOutlinenew PdfAction("http://iTextSharp.Sourceforge.Net"), "http://iTextSharp.Sourceforge.Net"));
34:                   cb.AddOutline(new PdfOutline(cb.RootOutlinenew PdfAction("Chap1102b.pdf"3), "Chap1102b.pdf"));
35:               }
36:               catch (Exception de
37:               {
38:                   Console.WriteLine(de.Message);
39:                   Console.WriteLine(de.StackTrace);
40:               }
41:           
42:               // step 5: we close the document
43:               document.Close();
44:           }
45:       }
46:   }