Class PdfRichMediaContent
Represents the rich media annotation content.
Inheritance
System.Object
PdfRichMediaContent
Namespace: Syncfusion.Pdf.Interactive
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfRichMediaContent : Object
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Create a new page .
PdfPage page = document.Pages.Add();
//Create a new rectangle
RectangleF rectangle = new RectangleF(10, 40, 30, 30);
//create the new rich media annotation
PdfRichMediaAnnotation richMediaAnnotation = new PdfRichMediaAnnotation(rect);
//create the rich media content
PdfRichMediaContent content = new PdfRichMediaContent("Video.mp4", PdfRichMediaContentType.Video);
richMediaAnnotation.Content = content;
//Set the rich media activation mode
richMediaAnnotation.ActivationMode = PdfRichMediaActivationMode.Click;
//Set the rich media presentation
richMediaAnnotation.PresentationStyle = PdfRichMediaPresentationStyle.Windowed;
//Add this annotation to a new page.
page.Annotations.Add(richMediaAnnotation);
//Save the document to disk.
document.Save("RichMediaAnnotation.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Create a new page .
Dim page As PdfPage = document.Pages.Add()
'Create a new rectangle
Dim rectangle As New RectangleF(10, 40, 30, 30)
'Create a new rich media annotation.
Dim richMediaAnnotation As New PdfRichMediaAnnotation(rectangle)
'Create a rich media annotation content
Dim content As New PdfRichMediaContent("Video.mp4", PdfRichMediaContentType.Video)
richMediaAnnotation.Content = content
'Set the rich media activation mode
richMediaAnnotation.ActivationMode = PdfRichMediaActivationMode.Click
'Set the rich media presentation
richMediaAnnotation.PresentationStyle = PdfRichMediaPresentationStyle.Windowed
'Add this annotation to a new page.
page.Annotations.Add(richMediaAnnotation)
'Save the document to disk.
document.Save("RichMediaAnnotation.pdf")
'Close the document
document.Close(True)
Constructors
PdfRichMediaContent(String)
Initializes a new instance of the PdfRichMediaContent class.
Declaration
public PdfRichMediaContent(string mediaFileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | mediaFileName | The media file name. |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Create a new page .
PdfPage page = document.Pages.Add();
//Create a new rectangle
RectangleF rectangle = new RectangleF(10, 40, 30, 30);
//Create the new rich media annotation
PdfRichMediaAnnotation richMediaAnnotation = new PdfRichMediaAnnotation(rect);
//Create the rich media content
PdfRichMediaContent content = new PdfRichMediaContent("Video.mp4");
richMediaAnnotation.Content = content;
//Set the rich media activation mode
richMediaAnnotation.ActivationMode = PdfRichMediaActivationMode.Click;
//Set the rich media presentation
richMediaAnnotation.PresentationStyle = PdfRichMediaPresentationStyle.Windowed;
//Add this annotation to a new page.
page.Annotations.Add(richMediaAnnotation);
//Save the document to disk.
document.Save("RichMediaAnnotation.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Create a new page.
Dim page As PdfPage = document.Pages.Add()
'Create a new rectangle
Dim rectangle As New RectangleF(10, 40, 30, 30)
'Create a new rich media annotation.
Dim richMediaAnnotation As New PdfRichMediaAnnotation(rectangle)
'Create a rich media annotation content
Dim content As New PdfRichMediaContent("Video.mp4")
richMediaAnnotation.Content = content
'Set the rich media activation mode
richMediaAnnotation.ActivationMode = PdfRichMediaActivationMode.Click
'Set the rich media presentation
richMediaAnnotation.PresentationStyle = PdfRichMediaPresentationStyle.Windowed
'Add this annotation to a new page.
page.Annotations.Add(richMediaAnnotation)
'Save the document to disk.
document.Save("RichMediaAnnotation.pdf")
'Close the document
document.Close(True)
PdfRichMediaContent(String, PdfRichMediaContentType)
Initializes a new instance of the PdfRichMediaContent class.
Declaration
public PdfRichMediaContent(string mediaFileName, PdfRichMediaContentType type)
Parameters
Type | Name | Description |
---|---|---|
System.String | mediaFileName | The media file name. |
PdfRichMediaContentType | type | The rich media content type. |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Create a new page .
PdfPage page = document.Pages.Add();
//Create a new rectangle
RectangleF rectangle = new RectangleF(10, 40, 30, 30);
//Create the new rich media annotation
PdfRichMediaAnnotation richMediaAnnotation = new PdfRichMediaAnnotation(rect);
//Create the rich media content
PdfRichMediaContent content = new PdfRichMediaContent("Video.mp4", PdfRichMediaContentType.Video);
richMediaAnnotation.Content = content;
//Set the rich media activation mode
richMediaAnnotation.ActivationMode = PdfRichMediaActivationMode.Click;
//Set the rich media presentation
richMediaAnnotation.PresentationStyle = PdfRichMediaPresentationStyle.Windowed;
//Add this annotation to a new page.
page.Annotations.Add(richMediaAnnotation);
//Save the document to disk.
document.Save("RichMediaAnnotation.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Create a new page .
Dim page As PdfPage = document.Pages.Add()
'Create a new rectangle
Dim rectangle As New RectangleF(10, 40, 30, 30)
'Create a new rich media annotation.
Dim richMediaAnnotation As New PdfRichMediaAnnotation(rectangle)
'Create a rich media annotation content
Dim content As New PdfRichMediaContent("Video.mp4", PdfRichMediaContentType.Video)
richMediaAnnotation.Content = content
'Set the rich media activation mode
richMediaAnnotation.ActivationMode = PdfRichMediaActivationMode.Click
'Set the rich media presentation
richMediaAnnotation.PresentationStyle = PdfRichMediaPresentationStyle.Windowed
'Add this annotation to a new page.
page.Annotations.Add(richMediaAnnotation)
'Save the document to disk.
document.Save("RichMediaAnnotation.pdf")
'Close the document
document.Close(True)
PdfRichMediaContent(String, Stream, String)
Initializes a new instance of the PdfRichMediaContent class.
Declaration
public PdfRichMediaContent(string name, Stream mediaFileStream, string fileExtension)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name |
System.IO.Stream | mediaFileStream | The media file stream. |
System.String | fileExtension | The media file extension. |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Create a new page .
PdfPage page = document.Pages.Add();
//Create a new rectangle
RectangleF rectangle = new RectangleF(10, 40, 30, 30);
//Create the new rich media annotation
PdfRichMediaAnnotation richMediaAnnotation = new PdfRichMediaAnnotation(rect);
//Load the sound as stream.
FileStream stream = new FileStream(@"Sound.mp3", FileMode.Open);
//Create the rich media content
PdfRichMediaContent content = new PdfRichMediaContent("Sound",stream,"mp3");
richMediaAnnotation.Content = content;
//Set the rich media activation mode
richMediaAnnotation.ActivationMode = PdfRichMediaActivationMode.Click;
//Set the rich media presentation
richMediaAnnotation.PresentationStyle = PdfRichMediaPresentationStyle.Windowed;
//Add this annotation to a new page.
page.Annotations.Add(richMediaAnnotation);
//Save the document to disk.
document.Save("RichMediaAnnotation.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Create a new page .
Dim page As PdfPage = document.Pages.Add()
'Create a new rectangle
Dim rectangle As New RectangleF(10, 40, 30, 30)
'Create a new rich media annotation.
Dim richMediaAnnotation As New PdfRichMediaAnnotation(rectangle)
'Load the sound as stream.
Dim stream As New FileStream("sound.mp3", FileMode.Open)
'Create a rich media annotation content
Dim content As New PdfRichMediaContent("sound",stream,"mp3")
richMediaAnnotation.Content = content
'Set the rich media activation mode
richMediaAnnotation.ActivationMode = PdfRichMediaActivationMode.Click
'Set the rich media presentation
richMediaAnnotation.PresentationStyle = PdfRichMediaPresentationStyle.Windowed
'Add this annotation to a new page.
page.Annotations.Add(richMediaAnnotation)
'Save the document to disk.
document.Save("RichMediaAnnotation.pdf")
'Close the document
document.Close(True)
PdfRichMediaContent(String, Stream, String, PdfRichMediaContentType)
Initializes a new instance of the PdfRichMediaContent class.
Declaration
public PdfRichMediaContent(string name, Stream mediaFileStream, string fileExtension, PdfRichMediaContentType type)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name. |
System.IO.Stream | mediaFileStream | The media file stream. |
System.String | fileExtension | The media file extension. |
PdfRichMediaContentType | type | The rich media content type. |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Create a new page .
PdfPage page = document.Pages.Add();
//Create a new rectangle
RectangleF rectangle = new RectangleF(10, 40, 30, 30);
//Create the new rich media annotation
PdfRichMediaAnnotation richMediaAnnotation = new PdfRichMediaAnnotation(rect);
//Load the video as stream.
FileStream stream = new FileStream(@"video.mp4", FileMode.Open);
//Create the rich media content
PdfRichMediaContent content = new PdfRichMediaContent("Video",stream, "mp4", PdfRichMediaContentType.Video);
richMediaAnnotation.Content = content;
//Set the rich media activation mode
richMediaAnnotation.ActivationMode = PdfRichMediaActivationMode.Click;
//Set the rich media presentation
richMediaAnnotation.PresentationStyle = PdfRichMediaPresentationStyle.Windowed;
//Add this annotation to a new page.
page.Annotations.Add(richMediaAnnotation);
//Save the document to disk.
document.Save("RichMediaAnnotation.pdf");
//Close the document
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Create a new page .
Dim page As PdfPage = document.Pages.Add()
'Create a new rectangle
Dim rectangle As New RectangleF(10, 40, 30, 30)
'Create a new rich media annotation.
Dim richMediaAnnotation As New PdfRichMediaAnnotation(rectangle)
'Load the video as stream.
Dim stream As New FileStream("video.mp4", FileMode.Open)
'Create a rich media annotation content
Dim content As New PdfRichMediaContent("Video",stream, "mp4", PdfRichMediaContentType.Video)
richMediaAnnotation.Content = content
'Set the rich media activation mode
richMediaAnnotation.ActivationMode = PdfRichMediaActivationMode.Click
'Set the rich media presentation
richMediaAnnotation.PresentationStyle = PdfRichMediaPresentationStyle.Windowed
'Add this annotation to a new page.
page.Annotations.Add(richMediaAnnotation)
'Save the document to disk.
document.Save("RichMediaAnnotation.pdf")
'Close the document
document.Close(True)
Properties
ContentType
Gets or sets the content type.
Declaration
public PdfRichMediaContentType ContentType { get; set; }
Property Value
Type |
---|
PdfRichMediaContentType |
Examples
//Load an existing document.
PdfLoadedDocument document = new PdfLoadedDocument(@"..\..\Annotations.pdf");
//Gets the annotation from loaded document.
PdfLoadedRichMediaAnnotation richMediaAnnotation = document.Pages[0].Annotations[0] as PdfLoadedRichMediaAnnotation;
//Gets or sets the content type
richMediaAnnotation.Content.ContentType = PdfRichMediaContentType.Sound;
//Save the document.
document.Save("RichMediaAnnotation.pdf");
//Close the document
document.Close(true);
'Load an existing document.
Dim document As New PdfLoadedDocument("..\..\Annotations.pdf")
'Gets the annotation from loaded document.
Dim richMediaAnnotation As PdfLoadedRichMediaAnnotation = document.Pages(0).Annotations(0) as PdfLoadedRichMediaAnnotation
'Gets or sets the content type
richMediaAnnotation.Content.ContentType = PdfRichMediaContentType.Sound
'Save the document.
document.Save("RichMediaAnnotation.pdf")
//Close the document
document.Close(True)
Data
Get the rich media data
Declaration
public Stream Data { get; }
Property Value
Type |
---|
System.IO.Stream |
Examples
//Load an existing document.
PdfLoadedDocument document = new PdfLoadedDocument(@"..\..\Annotations.pdf");
//Gets the annotation from loaded document.
PdfLoadedRichMediaAnnotation richMediaAnnotation = document.Pages[0].Annotations[0] as PdfLoadedRichMediaAnnotation;
//Gets the content
var content = richMediaAnnotation.Content.Data;
Save the content data
File.WriteAllBytes("RichMediaContent.mp4",(content as MemoryStream).ToArray());
//Save the document.
document.Save("RichMediaAnnotation.pdf");
//Close the document
document.Close(true);
'Load an existing document.
Dim document As New PdfLoadedDocument("..\..\Annotations.pdf")
'Gets the annotation from loaded document.
Dim richMediaAnnotation As PdfLoadedRichMediaAnnotation = document.Pages(0).Annotations(0) as PdfLoadedRichMediaAnnotation
'Gets the content
var content = richMediaAnnotation.Content.Data
Save the content data
File.WriteAllBytes("RichMediaContent.mp4",(content as MemoryStream).ToArray())
'Save the document.
document.Save("RichMediaAnnotation.pdf")
//Close the document
document.Close(True)
FileExtension
Gets or sets the file extension.
Declaration
public string FileExtension { get; set; }
Property Value
Type |
---|
System.String |
Examples
//Load an existing document.
PdfLoadedDocument document = new PdfLoadedDocument(@"..\..\Annotations.pdf");
//Gets the annotation from loaded document.
PdfLoadedRichMediaAnnotation richMediaAnnotation = document.Pages[0].Annotations[0] as PdfLoadedRichMediaAnnotation;
//Gets or sets the file extension
richMediaAnnotation.Content.FileExtension=".mp4";
//Save the document.
document.Save("RichMediaAnnotation.pdf");
//Close the document
document.Close(true);
'Load an existing document.
Dim document As New PdfLoadedDocument("..\..\Annotations.pdf")
'Gets the annotation from loaded document.
Dim richMediaAnnotation As PdfLoadedRichMediaAnnotation = document.Pages(0).Annotations(0) as PdfLoadedRichMediaAnnotation
'Gets or sets the file extension
richMediaAnnotation.Content.FileExtension=".mp4"
'Save the document.
document.Save("RichMediaAnnotation.pdf")
//Close the document
document.Close(True)
FileName
Gets or sets the file name.
Declaration
public string FileName { get; set; }
Property Value
Type |
---|
System.String |
Examples
//Load an existing document.
PdfLoadedDocument document = new PdfLoadedDocument(@"..\..\Annotations.pdf");
//Gets the annotation from loaded document.
PdfLoadedRichMediaAnnotation richMediaAnnotation = document.Pages[0].Annotations[0] as PdfLoadedRichMediaAnnotation;
//Gets or sets the file name.
richMediaAnnotation.Content.FileName = "Rich media annotation";
//Save the document.
document.Save("RichMediaAnnotation.pdf");
//Close the document
document.Close(true);
'Load an existing document.
Dim document As New PdfLoadedDocument("..\..\Annotations.pdf")
'Gets the annotation from loaded document.
Dim richMediaAnnotation As PdfLoadedRichMediaAnnotation = document.Pages(0).Annotations(0) as PdfLoadedRichMediaAnnotation
'Gets or sets the file name.
richMediaAnnotation.Content.FileName = "Rich media annotation"
'Save the document.
document.Save("RichMediaAnnotation.pdf")
//Close the document
document.Close(True);