'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsSystem.DrawingImportsGrapeCity.Documents.PdfImportsGrapeCity.Documents.TextImportsGrapeCity.Documents.Pdf.Annotations '' This sample shows how to add sound annotations to a PDF document.PublicClassSoundAnnotationsSubCreatePDF(ByVal stream AsStream)Dim doc = NewGcPdfDocument()Dim page = doc.NewPage()Dim g = page.Graphics'' User names for annotations' authors:Dim user1 = "Aiff Ding"Dim user2 = "Wav Dong" Dim tf = NewTextFormat() With {.Font = StandardFonts.Helvetica, .FontSize = 10}Dim noteWidth = 72 * 3Dim gap = 8 Dim rc = 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:Dim ip = NewPointF(rc.X, rc.Bottom + gap) rc = 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))Dim aiffAnnot = NewSoundAnnotation() With { .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 = 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))Dim wavAnnot = NewSoundAnnotation() With { .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)EndSubEndClass