Table of Contents

Class PdfRichMediaContent

Namespace
Syncfusion.Pdf.Interactive
Assembly
Syncfusion.Pdf.Portable.dll

Represents the rich media annotation content.

public class PdfRichMediaContent
Inheritance
PdfRichMediaContent
Inherited Members

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, Stream, string)

Initializes a new instance of the PdfRichMediaContent class.

public PdfRichMediaContent(string name, Stream mediaFileStream, string fileExtension)

Parameters

name string

The name

mediaFileStream Stream

The media file stream.

fileExtension string

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.

public PdfRichMediaContent(string name, Stream mediaFileStream, string fileExtension, PdfRichMediaContentType type)

Parameters

name string

The name.

mediaFileStream Stream

The media file stream.

fileExtension string

The media file extension.

type PdfRichMediaContentType

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.

public PdfRichMediaContentType ContentType { get; set; }

Property Value

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

public Stream Data { get; }

Property Value

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.

public string FileExtension { get; set; }

Property Value

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.

public string FileName { get; set; }

Property Value

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);