'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsSystem.DrawingImportsGrapeCity.Documents.PdfImportsGrapeCity.Documents.Pdf.Annotations '' Demonstrates how to create destinations and associate them with'' outline nodes or links in the document body.PublicClassDestinationsFunctionCreatePDF(ByVal stream AsStream) AsIntegerDim doc = NewGcPdfDocument() Dim page0 = doc.NewPage()Dim page1 = doc.NewPage()Dim page2 = doc.NewPage() Dim mainNote = Util.AddNote("This is page 1." + vbLf + vbLf + vbLf +"Demo of various destination types." + vbLf + vbLf +"Destinations attached to nodes in the document's outline tree:" + vbLf +" - Page 1: goes to this page, fits whole page" + vbLf +" - Page 2: goes to page 2, fits whole page" + vbLf +" -- Note 2, zoom 200%: goes to note 2 on page 2, zooms to 200%" + vbLf +" -- Zoom 100%: zooms to whole page 2" + vbLf +" -- Back to page 1: goes back to this page" + vbLf +" - Page 3: goes to page 3, fits whole page" + vbLf +" -- Zoom to note on page 3: zooms to whole note on page 3" + vbLf +" -- Back to page 1: goes back to this page" + vbLf +" - Named destinations: keyed by names in NamedDestinations dictionary:" + vbLf +" -- page1" + vbLf +" -- page2" + vbLf +" -- page3" + vbLf + vbLf +"Destinations associated with areas in the document body:", page0)Util.AddNote("This is page 2.", page1)Dim noteOnPage2 = Util.AddNote("Note 2 on page 2.", page1, NewRectangleF(300, 400, 200, 300))Util.AddNote("This is page 3", page2)Dim noteOnPage3 = Util.AddNote("This is a somewhat longer" + vbLf + "(even though not really long)" + vbLf + "note on page 3.", page2, NewRectangleF(200, 440, 200, 300)) '' Destinations in the outline tree: '' DestinationFit: fits whole page:Dim on1 = NewOutlineNode("Page 1", NewDestinationFit(page0)) doc.Outlines.Add(on1) Dim on2 = NewOutlineNode("Page 2", NewDestinationFit(page1)) doc.Outlines.Add(on2)'' DestinationXYZ: allows specifying top/left coordinates and the zoom level (1 is 100%): on2.Children.Add(NewOutlineNode("Note 2, zoom 200%", NewDestinationXYZ(page1, noteOnPage2.X, noteOnPage2.Y, 2))) on2.Children.Add(NewOutlineNode("Zoom 100%", NewDestinationXYZ(page1, Nothing, Nothing, 1)))'' Add a link back to page 1: on2.Children.Add(NewOutlineNode("Back to page 1", NewDestinationFit(page0))) Dim on3 = NewOutlineNode("Page 3", NewDestinationFit(page2)) doc.Outlines.Add(on3)'' DestinationFitR: fits a rectangle on page: on3.Children.Add(NewOutlineNode("Zoom to note on page 3", NewDestinationFitR(page2, noteOnPage3)))'' Add links back to page 1 & 2: on3.Children.Add(NewOutlineNode("Go to page 2", NewDestinationFit(page1))) on3.Children.Add(NewOutlineNode("Go to page 1", NewDestinationFit(page0))) '' Destinations in the document body (reusing destinations from the outlines):'' Go to page 2:Dim rc = Util.AddNote("Go to page 2", page0, NewRectangleF(72, mainNote.Bottom + 18, 200, 72)) page0.Annotations.Add(NewLinkAnnotation(rc, on2.Dest))'' Go to page 3: rc = Util.AddNote("Go to page 3", page0, NewRectangleF(72, rc.Bottom + 18, 200, 72)) page0.Annotations.Add(NewLinkAnnotation(rc, on3.Dest)) '' Destinations can also be named and added to the document's NamedDestinations dictionary. doc.NamedDestinations.Add("page1", NewDestinationFit(page0)) doc.NamedDestinations.Add("page2", NewDestinationFit(page1)) doc.NamedDestinations.Add("page3", NewDestinationFit(page2))'' Then they can be referenced using DestinationRef class, here we add them to the outline:Dim onNamed = NewOutlineNode("Named destinations", CType(Nothing, DestinationBase)) doc.Outlines.Add(onNamed) onNamed.Children.Add(NewOutlineNode("Named: page1", NewDestinationRef("page1"))) onNamed.Children.Add(NewOutlineNode("Named: page2", NewDestinationRef("page2"))) onNamed.Children.Add(NewOutlineNode("Named: page3", NewDestinationRef("page3")))'''' Done: doc.Save(stream)Return doc.Pages.CountEndFunctionEndClass