internal void AddNamedDestination(string destinationName, int destinationPage, PdfNamedDestinationParameters parameters) { if (_dests == null) { _dests = new PdfNameTreeNode(true); Owner.Internals.AddObject(_dests); Elements.SetReference(Keys.Dests, _dests.Reference); } // destIndex > Owner.PageCount can happen when rendering pages using PDFsharp directly. int destIndex = destinationPage; if (destIndex > Owner.PageCount) { destIndex = Owner.PageCount; } destIndex--; PdfPage dest = Owner.Pages[destIndex]; #if true PdfArray destination = new PdfArray(Owner, new PdfLiteral("{0} 0 R {1}", dest.ObjectNumber, parameters)); _dests.AddName(destinationName, destination); #else // Insert reference to destination dictionary instead of inserting the destination array directly. PdfArray destination = new PdfArray(Owner, new PdfLiteral("{0} 0 R {1}", dest.ObjectNumber, parameters)); PdfDictionary destinationDict = new PdfDictionary(Owner); destinationDict.Elements.SetObject("/D", destination); Owner.Internals.AddObject(destinationDict); _dests.AddName(destinationName, destinationDict.Reference); #endif }
/// <summary> /// Adds a named destination to the document. /// </summary> /// <param name="destinationName">The Named Destination's name.</param> /// <param name="destinationPage">The page to navigate to.</param> /// <param name="parameters">The PdfNamedDestinationParameters defining the named destination's parameters.</param> public void AddNamedDestination(string destinationName, int destinationPage, PdfNamedDestinationParameters parameters) { Internals.Catalog.Names.AddNamedDestination(destinationName, destinationPage, parameters); }