How to Start Convert PDF Read PDF Build PDF Work with PDF Modules PDF Document PDF Pages Text Image Graph & Path Annotation, Markup & Drawing Redaction Security Digital Signature Forms Watermark Bookmark Link File Attachment File Metadata Printing Work with Other SDKs Barcode read Barcode create OCR Twain

C# PDF Reader SDK Library
How to display, show, edit PDF file bookmark outline using c# in wpf, winform, asp.net


Empower Your C# Project with Rapid PDF Internal Navigation Via Bookmark and Outline in .NET Program









  • An advanced PDF SDK able to edit PDF bookmark in Visual C# .NET console application
  • Free trial library and components for navigate PDF with bookmark in C# .NET WinForms and ASP.NET program
  • Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint
  • C# demo code for editing PDF bookmarks in Visual Studio .NET class
  • Help to add or insert bookmark and outline into PDF file in .NET framework
  • Ability to remove and delete bookmark and outline from PDF document
  • Merge and split PDF file with bookmark
  • Save PDF file with bookmark open


RasterEdge XDoc.PDF SDK package provides PDF file navigation features for your C# project. On this C# tutorial, you will learn how to retrieve, edit and update PDF bookmark and outline.







Read PDF document outline using c#


Please directly copy and paste C# demo code below to your project to retrieve PDF file outline.



String inputFilePath = Program.RootPath + "\\" + "2.pdf";
PDFDocument doc = new PDFDocument(inputFilePath); 
REOutline outline = doc.GetOutline();
foreach (REEntry entry in outline.Entry)
{
    Console.WriteLine("Page:     " + entry.GetPageIndex());
    Console.WriteLine("Level:    " + entry.GetLevel());
    Console.WriteLine("Position: " + entry.GetLocation());
    Console.WriteLine("Text:     " + entry.GetText());
}




Update PDF document outline using c#


String inputFilePath = Program.RootPath + "\\" + "2.pdf";
String outputFilePath = Program.RootPath + "\\" + "Output_Outline.pdf";
PDFDocument doc = new PDFDocument(inputFilePath);

//  initial a new outline object
REOutline outline = new REOutline();

//  create 1st entry: Level = 1; Location: page index 0, y = 50
OutLine entryChapter1 = new OutLine("Chapter 1: *******", 1, 0, 50);
//  add 1st entry to outline
outline.Entry.Add(entryChapter1);

//  create 1st entry's child entries
//  create 1st child entry: Level = 2; Location: page index 1, y = 0
OutLine entryChapter11 = new OutLine("###### #### #### #### ###", 2, 1, 0);
//  connect this entry to the parent entry
entryChapter11.SetParentREEntry(entryChapter1);
//  add 1st child of 1st entry to outline
outline.Entry.Add(entryChapter11);

//  create 2nd child entry: Level = 2; Location: page index 2, y = 0
OutLine entryChapter12 = new OutLine("## ## ## ## ## #### ###", 2, 2, 0);
//  connect this entry to the parent entry
entryChapter12.SetParentREEntry(entryChapter1);
//  add 2nd child of 1st entry to outline
outline.Entry.Add(entryChapter12);

//  create 2nd entry: Level = 1; Location: page index 3, y = 100
OutLine entryChapter2 = new OutLine("Chapter 2: ******* ****", 1, 3, 100);
//  add 2nd entry to outline
outline.Entry.Add(entryChapter2);

//  create 3rd entry: Level = 1; Location: page index 5, y = 200
OutLine entryChapter3 = new OutLine("Chapter 3: **** **** ***", 1, 5, 200);
//  add 3rd entry to outline
outline.Entry.Add(entryChapter3);

//  create 3rd entry's child entries
//  create 1st child entry: Level = 2; Location: page index 9, y = 0
OutLine entryChapter31 = new OutLine("# #### ###", 2, 9, 0);
//  connect this entry to the parent entry
entryChapter31.SetParentREEntry(entryChapter3);
//  add 1st child of 3rd entry to outline
outline.Entry.Add(entryChapter31);

//  create a child entry for the 1st child entry of the 3rd entry
//  create entry: Level = 3; Location: page index 9, y = 500
OutLine entryChapter311 = new OutLine("???? ???? ??? ???", 3, 9, 500);
//  connect this entry to the parent entry
entryChapter311.SetParentREEntry(entryChapter31);
//  add 1st child of 3rd entry to outline
outline.Entry.Add(entryChapter311);

//  create 4th entry: Level = 1; Location: page index 10, y = 0
OutLine entryChapter4 = new OutLine("Chapter 4: ******* ** ** **** ***", 1, 10, 0);
//  add 4th entry to outline
outline.Entry.Add(entryChapter4);

//  create 5th entry: Level = 1; Location: page index 20, y = 0
OutLine entryChapter5 = new OutLine("Chapter 5: * ** **** **** ****", 1, 20, 0);
//  add 5th entry to outline
outline.Entry.Add(entryChapter5);

//  update the new outline
doc.SetOutline(outline);

doc.Save(outputFilePath);