Home Features Download License Tutorial Version History Source Code
This sample shows how to add document outlines (bookmarks) in your PDF file.
Use PDFOutline class to outline.
using PDFMosaic; using System; namespace Outlines { class Oultines { static void Main() { PDFDocument document = new PDFDocument(); document.Pages.Add(new PDFPage(PDFPaperFormat.A4)); document.PageMode = PDFPageMode.Outlines; PDFOutline first = new PDFOutline("First"); PDFOutline tmp = new PDFOutline("Bold Title"); tmp.Bold = true; first.Kids.Add(tmp); tmp.Bold = false; tmp.Italic = true; tmp.Title = "Italic Title"; first.Kids.Add(tmp); tmp.Bold = true; tmp.Title = "Bold Italic Title"; first.Kids.Add(tmp); document.Outlines.Add(first); PDFOutline second = new PDFOutline("Second"); tmp.Bold = false; tmp.Italic = false; tmp.Title = "Red"; tmp.Color = new PDFColorRGB(255, 0, 0); second.Kids.Add(tmp); tmp.Title = "Green"; tmp.Color = new PDFColorRGB(0, 255, 0); second.Kids.Add(tmp); tmp.Title = "blue"; tmp.Color = new PDFColorRGB(0, 0, 255); second.Kids.Add(tmp); document.Outlines.Add(second); PDFOutline third = new PDFOutline("Hidden Children"); for (int i = 0; i < 10; ++i) third.Kids.Add(new PDFOutline("Kid " + (i + 1).ToString())); third.HideChildren = true; document.Outlines.Add(third); document.Save("TestAddOutlines.pdf", true); } } }
Home Features Download License Tutorial Version History Source Code