Skip to main content
All docs
V26.1
  • SoundAnnotation Class

    An annotation that contains a sound recorded or imported form a file.

    Namespace: DevExpress.Docs.Pdf

    Assembly: DevExpress.Docs.Pdf.v26.1.dll

    NuGet Package: DevExpress.Docs.Pdf

    Declaration

    public class SoundAnnotation :
        MarkupAnnotation

    Example

    How to: Create a Sound Annotation

    The following code snippet creates a sound annotation and embeds a WAV audio file:

    sound annotation pdf api for dot net

    using DevExpress.Docs.Pdf;
    using System.Drawing;
    
    using (PdfDocument pdfDocument =
        new PdfDocument(File.OpenRead(@"Document.pdf")))
    {
        // Create a sound annotation
        SoundAnnotation annotation =
                    new SoundAnnotation(
                            new RectangleF(50, 420, 20, 20));
    
        annotation.Title = "John Smith";
        annotation.Content = "Voice note";
        annotation.IconName = SoundAnnotationIconName.Mic;
    
        // Load sound data from a WAV file
        Sound sound = new Sound();
        sound.SamplingRate = 44100;
        sound.SoundChannels = 2;
        sound.BitsPerSample = 16;
        sound.Encoding = SoundEncoding.Raw;
        sound.Data = File.ReadAllBytes(Path.Combine(Directory.GetCurrentDirectory(), "VoiceNote.wav"));
        annotation.Sound = sound;
    
        //  Add the annotation to the first page of the PDF document
        pdfDocument.Pages[0].Annotations.Add(annotation);
    
        pdfDocument.Save(File.OpenWrite(@"DocumentWithAnnotation.pdf"));
    }
    

    Implements

    Inheritance

    See Also