//// This code is part of Document Solutions for PDF .NET demos.// Copyright (c) MESCIUS inc. All rights reserved.//usingSystem.IO;usingSystem.Drawing;usingGrapeCity.Documents.Pdf;usingGrapeCity.Documents.Pdf.Annotations; namespaceDsPdfWeb.Demos.Basics{// This sample shows how to add sound annotations to a PDF document.publicclassSoundAnnotations {publicintCreatePDF(Stream stream) {var doc = newGcPdfDocument();var page = doc.NewPage();var noteWidth = 72 * 3;var gap = 8;// User names for annotations' authors:var user1 = "Aiff Ding";var user2 = "Wav Dong"; var rc = Common.Util.AddNote("This sample demonstrates adding sound annotations using DsPdf. " +"The track associated with an annotation can be played in a viewer that supports it. " +"PDF supports AIFF and WAV tracks in sound annotations.", page); // AIFF sound annotation:var ip = newPointF(rc.X, rc.Bottom + gap); rc = Common.Util.AddNote("A red sound annotation is placed to the right of this note. Double click the icon to play the sound.", page, newRectangleF(ip.X, ip.Y, noteWidth, 100));var aiffAnnot = newSoundAnnotation() {UserName = user1,Contents = "Sound annotation with an AIFF track.",Rect = newRectangleF(rc.Right, rc.Top, 24, 24),Icon = SoundAnnotationIcon.Speaker,Color = Color.Red,Sound = SoundObject.FromFile(Path.Combine("Resources", "Sounds", "ding.aiff"), AudioFormat.Aiff) }; page.Annotations.Add(aiffAnnot); // WAV sound annotation: ip = newPointF(rc.X, rc.Bottom + gap); rc = Common.Util.AddNote("A blue sound annotation is placed to the right of this note. Double click the icon to play the sound.", page, newRectangleF(ip.X, ip.Y, noteWidth, 100));var wavAnnot = newSoundAnnotation() {UserName = user2,Contents = "Sound annotation with a WAV track.",Rect = newRectangleF(rc.Right, rc.Top, 24, 24),Icon = SoundAnnotationIcon.Mic,Color = Color.Blue,Sound = SoundObject.FromFile(Path.Combine("Resources", "Sounds", "dong.wav"), AudioFormat.Wav) }; page.Annotations.Add(wavAnnot); // Done: doc.Save(stream);return doc.Pages.Count; } }}