Class PdfSoundAction
- Namespace
- Syncfusion.Pdf.Interactive
- Assembly
- Syncfusion.Pdf.Portable.dll
Represents the sound action,sound action plays a specified music file in the PDF document
public class PdfSoundAction : PdfAction
- Inheritance
-
PdfSoundAction
- Inherited Members
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)
Remarks
This PdfSoundAction class is used to plays a music file in PDF document. Please refer the UG docuemntation link
Constructors
PdfSoundAction(Stream)
public PdfSoundAction(Stream data)
Parameters
data
Stream
- See Also
Properties
FileName
public string FileName { get; set; }
Property Value
- 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.
public bool Mix { get; set; }
Property Value
- bool
true
if mix; otherwise,false
.
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.
public bool Repeat { get; set; }
Property Value
- bool
true
if repeat; otherwise,false
.
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.
public PdfSound Sound { get; set; }
Property Value
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.
public bool Synchronous { get; set; }
Property Value
- bool
true
if synchronous; otherwise,false
.
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.
public float Volume { get; set; }
Property Value
- float
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.
protected override void Initialize()
- See Also