[]
        
(Showing Draft Content)

Sound Annotation

Sound annotation is analogous to a text annotation except that instead of a text note, it contains sound (.au, .aiff, or .wav format) imported from a file or recorded from the computer’s microphone. DsPdf provides SoundAnnotation class to enable users to apply sound annotations to the PDF file.

DsPdf demonstrating how to add sound annotation in a PDF document

Refer to the following example code to add a sound annotation to a PDF document:

public void CreateSoundAnnotation()
{
    GcPdfDocument doc = new GcPdfDocument();
    Page page = doc.NewPage();
    RectangleF rc = new RectangleF(50, 50, 250, 50);
    page.Graphics.DrawString("A red sound annotation is placed to the right of this note. Double click " +
        "the icon to play the sound.",
        new TextFormat() { Font = StandardFonts.Times, FontSize = 11 }, rc);

    //Create an instance of SoundAnnotation class and set its relevant properties
    var aiffAnnot = new SoundAnnotation()
    {
        UserName = "Jaime Smith",
        Contents = "Sound annotation with an AIFF track.",
        PdfRect = new RectangleF(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);
    doc.Save("SoundAnnotation.pdf");
}