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 }
internal void AddEmbeddedFile(string name, Stream stream) { if (_embeddedFiles == null) { _embeddedFiles = new PdfNameTreeNode(true); Owner.Internals.AddObject(_embeddedFiles); Elements.SetReference(Keys.EmbeddedFiles, _embeddedFiles.Reference); } var embeddedFileStream = new PdfEmbeddedFileStream(Owner, stream); var fileSpecification = new PdfFileSpecification(Owner, embeddedFileStream, name); Owner.Internals.AddObject(fileSpecification); _embeddedFiles.AddName(name, fileSpecification.Reference); }