Pdf - PdfSoundEncoding

18 Nov 20261 minute to read

Public enum to define the audio encoding of a PdfSound resource.

// Create a new PDF document
let document: PdfDocument = new PdfDocument();
let page: PdfPage = document.addPage();
// Create and configure a sound resource
let sound: PdfSound = new PdfSound(soundData);
sound.bits = 16;
sound.channels = PdfSoundChannels.Stereo;
sound.encoding = PdfSoundEncoding.Signed;
sound.rate = 44100;
// Create a sound action
let action: PdfSoundAction = new PdfSoundAction(sound);
// Create a button and assign the action
let field: PdfButtonField = new PdfButtonField(
    page, 'PlaySound', { x: 20, y: 20, width: 120, height: 30 }
);
field.text = 'Play sound';
field.actions.mouseUp = action;
document.form.add(field);
// Save and destroy the document
document.save('output.pdf');
document.destroy();
  • ALaw - Specifies A-law audio encoding.
  • MuLaw - Specifies mu-law audio encoding.
  • Raw - Specifies raw audio encoding.
  • Signed - Specifies signed-integer audio encoding.