Samples: Outlines

   Minimize
  Outlines Sample for C# / VB.NET


Download the sample here
 
[C#]
PdfDocumentBuilder pdf = new PdfDocumentBuilder();
IPdfDocument document = pdf.CreateDocument();
document.ViewerPreferences.PageMode = PdfPageMode.UseOutlines;
document.Pages.AddNew();
//Create outline
IPdfOutlineItem outline = document.Outline.Add("Outlines", document.Pages[0]);
outline.Color = Color.DarkBlue;
outline.TextStyle = PdfTextStyle.Bold;
PdfFontStyle fontStyle = PdfFontStyle.Bold;
IPdfBrush brush = pdf.BrushFactory.CreateSolidBrush(outline.Color);
IPdfStandardFont font = pdf.FontFactory.CreateStandardFont(PdfStandardFontFamilies.TimesRoman, 24f, fontStyle);
PointF locationPoint = PointF.Empty;
document.Pages.AddNew();
//Create new outline
IPdfOutlineItem chapter1 = outline.Add("Chapter 1", document.Pages[1]);
//Set properties
chapter1.Color = Color.DarkBlue;
chapter1.TextStyle = PdfTextStyle.Italic;
chapter1.TextStyle = PdfTextStyle.Bold;
fontStyle = PdfFontStyle.Bold;
font = pdf.FontFactory.CreateStandardFont(PdfStandardFontFamilies.TimesRoman, 24f, fontStyle);
brush = pdf.BrushFactory.CreateSolidBrush(chapter1.Color);
locationPoint = new PointF(0, 0);
//Move to destination
chapter1.Destination.Location = locationPoint;
//create a child node in annotation
IPdfOutlineItem section11 = chapter1.Add("Section 1.1", document.Pages[1]);
//set properties
section11.Color = Color.DarkBlue;
section11.TextStyle = PdfTextStyle.Italic;
fontStyle = PdfFontStyle.Bold;
font = pdf.FontFactory.CreateStandardFont(PdfStandardFontFamilies.TimesRoman, 24f, fontStyle);
brush =pdf.BrushFactory.CreateSolidBrush(chapter1.Color);
locationPoint = new PointF(0, 40);
//Move to destination
section11.Destination.Location = locationPoint;
IPdfOutlineItem section12 = chapter1.Add("Section 1.2", document.Pages[1]);
section12.Color = Color.DarkBlue;
section12.TextStyle = PdfTextStyle.Italic;
fontStyle = PdfFontStyle.Bold;
font = pdf.FontFactory.CreateStandardFont(PdfStandardFontFamilies.TimesRoman, 24f, fontStyle);
brush = pdf.BrushFactory.CreateSolidBrush(section12.Color);
locationPoint = new PointF(0, 90);
section12.Destination.Location = locationPoint;
IPdfOutlineItem section13 = chapter1.Add("Section 1.3", document.Pages[1]);
section13.Color = Color.DarkBlue;
section13.TextStyle = PdfTextStyle.Italic;
fontStyle = PdfFontStyle.Bold;
font = pdf.FontFactory.CreateStandardFont(PdfStandardFontFamilies.TimesRoman, 24f, fontStyle);
brush = pdf.BrushFactory.CreateSolidBrush(section13.Color);
locationPoint = new PointF(0, 140);
section13.Destination.Location = locationPoint;
IPdfOutlineItem section14 = chapter1.Add("Section 1.4", document.Pages[1]);
section14.Color = Color.DarkBlue;
section14.TextStyle = PdfTextStyle.Italic;
fontStyle = PdfFontStyle.Bold;
font = pdf.FontFactory.CreateStandardFont(PdfStandardFontFamilies.TimesRoman, 24f, fontStyle);
brush = pdf.BrushFactory.CreateSolidBrush(section14.Color);
locationPoint = new PointF(0, 190);
section14.Destination.Location = locationPoint;
IPdfOutlineItem section15 = chapter1.Add("Section 1.5", document.Pages[1]);
section15.Color = Color.DarkBlue;
section15.TextStyle = PdfTextStyle.Italic;
fontStyle = PdfFontStyle.Bold;
font = pdf.FontFactory.CreateStandardFont(PdfStandardFontFamilies.TimesRoman, 24f, fontStyle);
brush = pdf.BrushFactory.CreateSolidBrush(section15.Color);
locationPoint = new PointF(0, 240);
section15.Destination.Location = locationPoint;
IPdfOutlineItem section16 = chapter1.Add("Section 1.6", document.Pages[1]);
section16.Color = Color.DarkBlue;
section16.TextStyle = PdfTextStyle.Italic;
fontStyle = PdfFontStyle.Bold;
font = pdf.FontFactory.CreateStandardFont(PdfStandardFontFamilies.TimesRoman, 24f, fontStyle);
brush = pdf.BrushFactory.CreateSolidBrush(section16.Color);
locationPoint = new PointF(0, 290);
section16.Destination.Location = locationPoint;
document.Pages.AddNew();
//Create new outline
IPdfOutlineItem chapter2 = outline.Add("Chapter 2", document.Pages[2]);
chapter2.TextStyle = PdfTextStyle.Italic;
chapter2.TextStyle = PdfTextStyle.Bold;
chapter2.Color = Color.DarkBlue;
fontStyle = PdfFontStyle.Bold;
font = pdf.FontFactory.CreateStandardFont(PdfStandardFontFamilies.TimesRoman, 16f, fontStyle);
brush = pdf.BrushFactory.CreateSolidBrush(chapter2.Color);
locationPoint = new PointF(10, 0);
chapter2.Destination.Location = locationPoint;
document.Pages[2].Graphics.DrawString(chapter2.Title, font, PdfBrushFactory.DarkBlue, locationPoint);
document.Pages.AddNew();
//Create new outline
IPdfOutlineItem chapter3 = outline.Add("Chapter 3", document.Pages[3]);
chapter3.TextStyle = PdfTextStyle.Italic;
chapter3.TextStyle = PdfTextStyle.Bold;
chapter3.Color = Color.DarkBlue;
fontStyle = PdfFontStyle.Bold;
font = pdf.FontFactory.CreateStandardFont(PdfStandardFontFamilies.TimesRoman, 16f, fontStyle);
brush = pdf.BrushFactory.CreateSolidBrush(chapter3.Color);
locationPoint = new PointF(30, 240);
          
document.Save(fileName);
[VB.NET]
Dim pdf As New PdfDocumentBuilder()
Dim document As IPdfDocument = pdf.CreateDocument()
document.ViewerPreferences.PageMode = PdfPageMode.UseOutlines
document.Pages.AddNew()
'Create outline
Dim outline As IPdfOutlineItem = document.Outline.Add("Outlines", document.Pages(0))
outline.Color = Color.DarkBlue
outline.TextStyle = PdfTextStyle.Bold
Dim fontStyle As PdfFontStyle = PdfFontStyle.Bold
Dim brush As IPdfBrush = pdf.BrushFactory.CreateSolidBrush(outline.Color)
Dim font As IPdfStandardFont = pdf.FontFactory.CreateStandardFont(PdfStandardFontFamilies.TimesRoman, 24.0F, fontStyle)
Dim locationPoint As PointF = PointF.Empty
document.Pages.AddNew()
'Create new outline
Dim chapter1 As IPdfOutlineItem = outline.Add("Chapter 1", document.Pages(1))
'Set properties 
chapter1.Color = Color.DarkBlue
chapter1.TextStyle = PdfTextStyle.Italic
chapter1.TextStyle = PdfTextStyle.Bold
fontStyle = PdfFontStyle.Bold
font = pdf.FontFactory.CreateStandardFont(PdfStandardFontFamilies.TimesRoman, 24.0F, fontStyle)
brush = pdf.BrushFactory.CreateSolidBrush(chapter1.Color)
locationPoint = New PointF(0, 0)
'Move to destination 
chapter1.Destination.Location = locationPoint
'create a child node in annotation 
Dim section11 As IPdfOutlineItem = chapter1.Add("Section 1.1", document.Pages(1))
'set properties 
section11.Color = Color.DarkBlue
section11.TextStyle = PdfTextStyle.Italic
fontStyle = PdfFontStyle.Bold
font = pdf.FontFactory.CreateStandardFont(PdfStandardFontFamilies.TimesRoman, 24.0F, fontStyle)
brush = pdf.BrushFactory.CreateSolidBrush(chapter1.Color)
locationPoint = New PointF(0, 40)
'Move to destination 
section11.Destination.Location = locationPoint
Dim section12 As IPdfOutlineItem = chapter1.Add("Section 1.2", document.Pages(1))
section12.Color = Color.DarkBlue
section12.TextStyle = PdfTextStyle.Italic
fontStyle = PdfFontStyle.Bold
font = pdf.FontFactory.CreateStandardFont(PdfStandardFontFamilies.TimesRoman, 24.0F, fontStyle)
brush = pdf.BrushFactory.CreateSolidBrush(section12.Color)
locationPoint = New PointF(0, 90)
section12.Destination.Location = locationPoint
Dim section13 As IPdfOutlineItem = chapter1.Add("Section 1.3", document.Pages(1))
section13.Color = Color.DarkBlue
section13.TextStyle = PdfTextStyle.Italic
fontStyle = PdfFontStyle.Bold
font = pdf.FontFactory.CreateStandardFont(PdfStandardFontFamilies.TimesRoman, 24.0F, fontStyle)
brush = pdf.BrushFactory.CreateSolidBrush(section13.Color)
locationPoint = New PointF(0, 140)
section13.Destination.Location = locationPoint
Dim section14 As IPdfOutlineItem = chapter1.Add("Section 1.4", document.Pages(1))
section14.Color = Color.DarkBlue
section14.TextStyle = PdfTextStyle.Italic
fontStyle = PdfFontStyle.Bold
font = pdf.FontFactory.CreateStandardFont(PdfStandardFontFamilies.TimesRoman, 24.0F, fontStyle)
brush = pdf.BrushFactory.CreateSolidBrush(section14.Color)
locationPoint = New PointF(0, 190)
section14.Destination.Location = locationPoint
Dim section15 As IPdfOutlineItem = chapter1.Add("Section 1.5", document.Pages(1))
section15.Color = Color.DarkBlue
section15.TextStyle = PdfTextStyle.Italic
fontStyle = PdfFontStyle.Bold
font = pdf.FontFactory.CreateStandardFont(PdfStandardFontFamilies.TimesRoman, 24.0F, fontStyle)
brush = pdf.BrushFactory.CreateSolidBrush(section15.Color)
locationPoint = New PointF(0, 240)
section15.Destination.Location = locationPoint
Dim section16 As IPdfOutlineItem = chapter1.Add("Section 1.6", document.Pages(1))
section16.Color = Color.DarkBlue
section16.TextStyle = PdfTextStyle.Italic
fontStyle = PdfFontStyle.Bold
font = pdf.FontFactory.CreateStandardFont(PdfStandardFontFamilies.TimesRoman, 24.0F, fontStyle)
brush = pdf.BrushFactory.CreateSolidBrush(section16.Color)
locationPoint = New PointF(0, 290)
section16.Destination.Location = locationPoint
document.Pages.AddNew()
'Create new outline
Dim chapter2 As IPdfOutlineItem = outline.Add("Chapter 2", document.Pages(2))
chapter2.TextStyle = PdfTextStyle.Italic
chapter2.TextStyle = PdfTextStyle.Bold
chapter2.Color = Color.DarkBlue
fontStyle = PdfFontStyle.Bold
font = pdf.FontFactory.CreateStandardFont(PdfStandardFontFamilies.TimesRoman, 16.0F, fontStyle)
brush = pdf.BrushFactory.CreateSolidBrush(chapter2.Color)
locationPoint = New PointF(10, 0)
chapter2.Destination.Location = locationPoint
document.Pages(2).Graphics.DrawString(chapter2.Title, font, PdfBrushFactory.DarkBlue, locationPoint)
document.Pages.AddNew()
'Create new outline
Dim chapter3 As IPdfOutlineItem = outline.Add("Chapter 3", document.Pages(3))
chapter3.TextStyle = PdfTextStyle.Italic
chapter3.TextStyle = PdfTextStyle.Bold
chapter3.Color = Color.DarkBlue
fontStyle = PdfFontStyle.Bold
font = pdf.FontFactory.CreateStandardFont(PdfStandardFontFamilies.TimesRoman, 16.0F, fontStyle)
brush = pdf.BrushFactory.CreateSolidBrush(chapter3.Color)
locationPoint = New PointF(30, 240)
document.Save(fileName)