PDF Mosaic: How to create a sound (audio) annotations in PDF document


Home       Features       Download       Tutorial       Version History       License       Source Code

 

PDF documents can contain annotations that appear on a page but are not considered to be part of the page content.

You can use PDF Mosaic library to add a pre-recorded WAV or AIFF files as a comment or to record and place an audio comment in a document. Audio attachments appear in the Comments list and can be played back on any platform. However, the appropriate hardware and software for playing audio files must be installed.

This sample shows how to add sound annotations to your PDF document. Use PDFTextAnnotation class to add sound annotation.

C# :

using PDFMosaic;
using System;
 
namespace SoundAnnotation
{
  class SoundAnnotation
  {
    static void Main(string[] args)
    {
      PDFDocument document = new PDFDocument();
      PDFPage page = new PDFPage(PDFPaperFormat.A4);
 
      PDFSound sound = new PDFSound("..\\..\\911.wav");
      PDFSoundAnnotation soundAnnotation = new PDFSoundAnnotation(sound, 20, 40, 15, 15);
      page.Annotations.Add(soundAnnotation);
 
      document.Pages.Add(page);
      document.Save("SoundAnnotation.pdf", true);
    }
  }
}

 

Visual Basic :

Imports PDFMosaic
Imports System
 
Module SoundAnnotation
  Sub Main()
    Dim document As New PDFDocument()
    Dim page As New PDFPage(PDFPaperFormat.A4)
 
    Dim sound As New PDFSound("..\\..\\911.wav")
    Dim soundAnnotation As New PDFSoundAnnotation(sound, 20, 40, 15, 15)
    page.Annotations.Add(soundAnnotation)
 
    document.Pages.Add(page)
    document.Save("SoundAnnotation.pdf", True)
  End Sub
End Module

 


Home       Features       Download       Tutorial       Version History       License       Source Code