DocumentBuilderInsertOnlineVideo(String, String, Byte, RelativeHorizontalPosition, Double, RelativeVerticalPosition, Double, Double, Double, WrapType) Method

Inserts an online video object into the document and scales it to the specified size.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.8.0


public Shape InsertOnlineVideo(
	string videoUrl,
	string videoEmbedCode,
	byte[] thumbnailImageBytes,
	RelativeHorizontalPosition horzPos,
	double left,
	RelativeVerticalPosition vertPos,
	double top,
	double width,
	double height,
	WrapType wrapType


Type: SystemString
The URL to the video.
Type: SystemString
The embed code for the video.
Type: SystemByte
The thumbnail image bytes.
Type: Aspose.Words.DrawingRelativeHorizontalPosition
Specifies where the distance to the image is measured from.
Type: SystemDouble
Distance in points from the origin to the left side of the image.
Type: Aspose.Words.DrawingRelativeVerticalPosition
Specifies where the distance to the image measured from.
Type: SystemDouble
Distance in points from the origin to the top side of the image.
Type: SystemDouble
The width of the image in points. Can be a negative or zero value to request 100% scale.
Type: SystemDouble
The height of the image in points. Can be a negative or zero value to request 100% scale.
Type: Aspose.Words.DrawingWrapType
Specifies how to wrap text around the image.

Return Value

Type: Shape
The image node that was just inserted.


You can change the image size, location, positioning method and other settings using the Shape object returned by this method.


Shows how to insert online video into a document using html code.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Visible url
string vimeoVideoUrl = @"";

// Embed Html code
string vimeoEmbedCode =
    "<iframe src=\"\" width=\"640\" height=\"360\" frameborder=\"0\" title=\"Aspose\" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>";

// This video will have an automatically generated thumbnail, and we are setting the size according to its 16:9 aspect ratio
builder.Writeln("Video with an automatically generated thumbnail at the top left corner of the page:");
builder.InsertOnlineVideo(vimeoVideoUrl, RelativeHorizontalPosition.LeftMargin, 0,
    RelativeVerticalPosition.TopMargin, 0, 320, 180, WrapType.Square);

// We can get an image to use as a custom thumbnail
using (WebClient webClient = new WebClient())
    byte[] imageBytes = webClient.DownloadData(AsposeLogoUrl);

    using (MemoryStream stream = new MemoryStream(imageBytes))
        using (Image image = Image.FromStream(stream))
            // This puts the video where we are with our document builder, with a custom thumbnail and size depending on the size of the image
            builder.Writeln("Custom thumbnail at document builder's cursor:");
            builder.InsertOnlineVideo(vimeoVideoUrl, vimeoEmbedCode, imageBytes, image.Width, image.Height);

            // We can put the video at the bottom right edge of the page too, but we'll have to take the page margins into account 
            double left = builder.PageSetup.RightMargin - image.Width;
            double top = builder.PageSetup.BottomMargin - image.Height;

            // Here we use a custom thumbnail and relative positioning to put it and the bottom right of tha page
            builder.Writeln("Bottom right of page with custom thumbnail:");

            builder.InsertOnlineVideo(vimeoVideoUrl, vimeoEmbedCode, imageBytes,
                RelativeHorizontalPosition.RightMargin, left, RelativeVerticalPosition.BottomMargin, top,
                image.Width, image.Height, WrapType.Square);

doc.Save(ArtifactsDir + "DocumentBuilder.InsertOnlineVideo.docx");

See Also