Class PdfSoundAction
Represents the sound action,sound action plays a specified music file in the PDF document
Inherited Members
Namespace: Syncfusion.Pdf.Interactive
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfSoundAction : PdfAction, IPdfWrapper
Remarks
This PdfSoundAction class is used to plays a music file in PDF document. Please refer the UG docuemntation link https://help.syncfusion.com/file-formats/pdf/working-with-action#sound-action for more details.
Examples
//Create a new document
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
//Create a sound action
PdfSoundAction soundAction = new PdfSoundAction("../../Data/Startup.wav");
soundAction.Sound.Bits = 16;
soundAction.Sound.Channels = PdfSoundChannels.Stereo;
soundAction.Sound.Encoding = PdfSoundEncoding.Signed;
soundAction.Volume = 0.9f;
//Set the sound action
document.Actions.AfterOpen = soundAction;
//Save and close the PDF document
document.Save("Output.pdf");
document.Close(true);
'Create a new document
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
'Create a sound action
Dim soundAction As New PdfSoundAction("../../Data/Startup.wav")
soundAction.Sound.Bits = 16
soundAction.Sound.Channels = PdfSoundChannels.Stereo
soundAction.Sound.Encoding = PdfSoundEncoding.Signed
soundAction.Volume = 0.9F
'Set the sound action
document.Actions.AfterOpen = soundAction
'Save and close the PDF
document.Save("Output.pdf")
document.Close(True)
Constructors
PdfSoundAction(String)
Declaration
public PdfSoundAction(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName |
Examples
//Create a new document
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
//Create a sound action
PdfSoundAction soundAction = new PdfSoundAction("../../Data/Startup.wav");
soundAction.Sound.Bits = 16;
soundAction.Sound.Channels = PdfSoundChannels.Stereo;
soundAction.Sound.Encoding = PdfSoundEncoding.Signed;
soundAction.Volume = 0.9f;
//Set the sound action
document.Actions.AfterOpen = soundAction;
//Save and close the PDF document
document.Save("Output.pdf");
document.Close(true);
'Create a new document
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
'Create a sound action
Dim soundAction As New PdfSoundAction("../../Data/Startup.wav")
soundAction.Sound.Bits = 16
soundAction.Sound.Channels = PdfSoundChannels.Stereo
soundAction.Sound.Encoding = PdfSoundEncoding.Signed
soundAction.Volume = 0.9F
'Set the sound action
document.Actions.AfterOpen = soundAction
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)
See Also
Properties
FileName
Declaration
public string FileName { get; set; }
Property Value
Type | Description |
---|---|
System.String | The name of the sound file. |
Examples
//Create a new document
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
//Create a sound action
PdfSoundAction soundAction = new PdfSoundAction("../../Data/Startup.wav");
soundAction.Sound.Bits = 16;
soundAction.Sound.Channels = PdfSoundChannels.Stereo;
soundAction.Sound.Encoding = PdfSoundEncoding.Signed;
soundAction.Volume = 0.9f;
//Get the fileName form soundAction
string fileName=soundAction.FileName;
//Set the sound action
document.Actions.AfterOpen = soundAction;
//Save and close the PDF document
document.Save("Output.pdf");
document.Close(true);
'Create a new document
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
'Create a sound action
Dim soundAction As New PdfSoundAction("../../Data/Startup.wav")
soundAction.Sound.Bits = 16
soundAction.Sound.Channels = PdfSoundChannels.Stereo
soundAction.Sound.Encoding = PdfSoundEncoding.Signed
soundAction.Volume = 0.9F
'Get the fileName form soundAction
Dim fileName as string =soundAction.FileName;
'Set the sound action
document.Actions.AfterOpen = soundAction
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)
See Also
Mix
Gets or sets a value indicating whether to mix this sound with any other sound already playing. If this flag is false, any previously playing sound is stopped before starting this sound; this can be used to stop a repeating sound. Default value: false.
Declaration
public bool Mix { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Examples
//Create a new document
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
//Create a sound action
PdfSoundAction soundAction = new PdfSoundAction("../../Data/Startup.wav");
soundAction.Sound.Bits = 16;
soundAction.Sound.Channels = PdfSoundChannels.Stereo;
soundAction.Sound.Encoding = PdfSoundEncoding.Signed;
soundAction.Volume = 0.9f;
soundAction.Mix = true;
//Set the sound action
document.Actions.AfterOpen = soundAction;
//Save and close the PDF document
document.Save("Output.pdf");
document.Close(true);
'Create a new document
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
'Create a sound action
Dim soundAction As New PdfSoundAction("../../Data/Startup.wav")
soundAction.Sound.Bits = 16
soundAction.Sound.Channels = PdfSoundChannels.Stereo
soundAction.Sound.Encoding = PdfSoundEncoding.Signed
soundAction.Volume = 0.9F
soundAction.Mix = True
'Set the sound action
document.Actions.AfterOpen = soundAction
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)
See Also
Repeat
Gets or sets a value indicating whether to repeat the sound indefinitely. If this entry is present, the Synchronous property is ignored. Default value: false.
Declaration
public bool Repeat { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Examples
//Create a new document
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
//Create a sound action
PdfSoundAction soundAction = new PdfSoundAction("../../Data/Startup.wav");
soundAction.Sound.Bits = 16;
soundAction.Sound.Channels = PdfSoundChannels.Stereo;
soundAction.Sound.Encoding = PdfSoundEncoding.Signed;
soundAction.Volume = 0.9f;
soundAction.Repeat = true;
//Set the sound action
document.Actions.AfterOpen = soundAction;
//Save and close the PDF document
document.Save("Output.pdf");
document.Close(true);
'Create a new document
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
'Create a sound action
Dim soundAction As New PdfSoundAction("../../Data/Startup.wav")
soundAction.Sound.Bits = 16
soundAction.Sound.Channels = PdfSoundChannels.Stereo
soundAction.Sound.Encoding = PdfSoundEncoding.Signed
soundAction.Volume = 0.9F
soundAction.Repeat = True
'Set the sound action
document.Actions.AfterOpen = soundAction
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)
See Also
Sound
Gets or sets the sound.
Declaration
public PdfSound Sound { get; set; }
Property Value
Type | Description |
---|---|
PdfSound |
Examples
//Create a new document
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
//Create a sound action
PdfSoundAction soundAction = new PdfSoundAction("../../Data/Startup.wav");
soundAction.Sound.Bits = 16;
soundAction.Sound.Channels = PdfSoundChannels.Stereo;
soundAction.Sound.Encoding = PdfSoundEncoding.Signed;
soundAction.Volume = 0.9f;
//Set the sound action
document.Actions.AfterOpen = soundAction;
//Save and close the PDF document
document.Save("Output.pdf");
document.Close(true);
'Create a new document
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
'Create a sound action
Dim soundAction As New PdfSoundAction("../../Data/Startup.wav")
soundAction.Sound.Bits = 16
soundAction.Sound.Channels = PdfSoundChannels.Stereo
soundAction.Sound.Encoding = PdfSoundEncoding.Signed
soundAction.Volume = 0.9F
'Set the sound action
document.Actions.AfterOpen = soundAction
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)
See Also
Synchronous
Gets or sets a value whether to play the sound synchronously or asynchronously. If this flag is true, the viewer application retains control, allowing no further user interaction other than canceling the sound, until the sound has been completely played. Default value: false.
Declaration
public bool Synchronous { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Examples
//Create a new document
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
//Create a sound action
PdfSoundAction soundAction = new PdfSoundAction("../../Data/Startup.wav");
soundAction.Sound.Bits = 16;
soundAction.Sound.Channels = PdfSoundChannels.Stereo;
soundAction.Sound.Encoding = PdfSoundEncoding.Signed;
soundAction.Volume = 0.9f;
soundAction.Synchronous = true;
//Set the sound action
document.Actions.AfterOpen = soundAction;
//Save and close the PDF document
document.Save("Output.pdf");
document.Close(true);
'Create a new document
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
'Create a sound action
Dim soundAction As New PdfSoundAction("../../Data/Startup.wav")
soundAction.Sound.Bits = 16
soundAction.Sound.Channels = PdfSoundChannels.Stereo
soundAction.Sound.Encoding = PdfSoundEncoding.Signed
soundAction.Volume = 0.9F
soundAction.Synchronous = True
'Set the sound action
document.Actions.AfterOpen = soundAction
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)
See Also
Volume
Gets or sets the volume at which to play the sound, in the range -1.0 to 1.0.
Declaration
public float Volume { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The volume of the sound. |
Examples
//Create a new document
PdfDocument document = new PdfDocument();
//Add a page.
PdfPage page = document.Pages.Add();
//Create a sound action
PdfSoundAction soundAction = new PdfSoundAction("../../Data/Startup.wav");
soundAction.Sound.Bits = 16;
soundAction.Sound.Channels = PdfSoundChannels.Stereo;
soundAction.Sound.Encoding = PdfSoundEncoding.Signed;
soundAction.Volume = 0.9f;
//Set the sound action
document.Actions.AfterOpen = soundAction;
//Save and close the PDF document
document.Save("Output.pdf");
document.Close(true);
'Create a new document
Dim document As New PdfDocument()
'Add a page.
Dim page As PdfPage = document.Pages.Add()
'Create a sound action
Dim soundAction As New PdfSoundAction("../../Data/Startup.wav")
soundAction.Sound.Bits = 16
soundAction.Sound.Channels = PdfSoundChannels.Stereo
soundAction.Sound.Encoding = PdfSoundEncoding.Signed
soundAction.Volume = 0.9F
'Set the sound action
document.Actions.AfterOpen = soundAction
'Save and close the PDF document
document.Save("Output.pdf")
document.Close(True)
See Also
Methods
Initialize()
Initializes instance.
Declaration
protected override void Initialize()