Getting Page Numbers From Outlines

Getting Page Numbers From Outlines

Forum member · Nov 13, 2008
I am able to access Outline text via document.Outlines(i).Text but can't seem to be able to get the Page Number that the Outline (bookmark) is associated with. I can see in your documentation that you can set a ZoomDestination when adding outlines to pages but need to get the page number from an already existing document. Can this be done?

Re: Getting Page Numbers From Outlines

Support · Nov 14, 2008
Hello, Yes, using our latest build you can read existing bookmark information. It will let you find out what page the bookmark in existing PDF document points to. You can get the latest build from our CustomerArea by logging in using your current serial number. Following is the sample code we used for testing in console application: using ceTe.DynamicPDF; using ceTe.DynamicPDF.PageElements; using ceTe.DynamicPDF.Merger; static void Main(string[] args) { Document document = OutlinePageNums(); document.Draw( "HelloWorld.pdf" ); Console.ReadLine(); } public static Document OutlinePageNums() { PdfDocument pdfDocument = new PdfDocument(@"C:\Temp\AllPageElements.pdf"); if (pdfDocument.Outlines != null) OutputOutlines(pdfDocument.Outlines); return new MergeDocument(pdfDocument); } public static void OutputOutlines(PdfOutlineList outlines) { for (int i = 0; i < outlines.Count; i++) { OutputOutline(outlines[i]); } } public static void OutputOutline(PdfOutline outline) { Console.WriteLine(outline.Text + " : " + outline.TargetPageNumber); if (outline.ChildOutlines != null && outline.ChildOutlines.Count > 0) OutputOutlines(outline.ChildOutlines); } Thanks, ceTe Software Support Team.