Creating Bookmarks in a PDF documentThe following code snippet creates PDF bookmarks that appear in the left side bar of Acrobat. c# sample: PDFCreationOptions options = new PDFCreationOptions(); options.Viewer.PageMode = PageMode.UseOutlines; PDFDocument MyPDF = new PDFDocument("Bookmarks.pdf", options); for(int i = 0; i < 10; i++) { if(i != 0) MyPDF.NewPage(); } PDFGoToPageAction act = MyPDF.CreateGoToPageAction(0, 0); PDFOutlineNode root = MyPDF.Outlines.Add(null, "Bookmarks", act, Charset.ANSI_CHARSET); root.Expanded = true; for(int i = 0; i < MyPDF.Pages.Count; i++) { // Create child bookmark act = MyPDF.CreateGoToPageAction(i, 0); PDFOutlineNode chapter = MyPDF.Outlines.AddChild(root, "Page " + (i + 1).ToString(), act, Charset.ANSI_CHARSET); chapter.Expanded = true; chapter.Color = Color.Blue; chapter.Style = FontStyle.Italic; } MyPDF.Save(); |
PDF .NET Library for .NET Software Developers - PDF Component Library for C#, VB.NET and ASP.NET developers Copyright © PDF Technologies Inc., 2010. |