AddVideoLink.cs
//
// This code is part of Document Solutions for Word demos.
// Copyright (c) MESCIUS inc. All rights reserved.
//
using System;
using System.IO;
using System.Drawing;
using System.Linq;
using System.Diagnostics;
using GrapeCity.Documents.Word;
using GrapeCity.Documents.Imaging;

namespace DsWordWeb.Demos
{
    // This demo shows how to add a link to a YouTube video that plays in the DOCX.
    public class AddVideoLink
    {
        public GcWordDocument CreateDocx()
        {
            var doc = new GcWordDocument();
            doc.Body.AddParagraph("The picture below includes a link to a YouTube video which plays inside the document if clicked.");
            // Add picture with a thumbnail and a video link inside:
            var vStyle = doc.Styles.Add("vlink_style", doc.Styles[BuiltInStyleId.BlockText]);
            vStyle.ParagraphFormat.Indentation.LeftIndent = 0;
            var par = doc.Body.AddParagraph();
            par.Style = vStyle;
            var pic = par.AddRun().AddPicture();
            var picBytes = File.ReadAllBytes(Path.Combine("Resources", "ImagesBis", "mescius-video-thumbnail.jpg"));
            pic.ImageData.SetImage(picBytes, "image/jpeg");
            pic.ImageData.WebVideoProperties.SetUrl("https://www.youtube.com/watch?v=RRTCt2TTOyU", "How to Build a Simple Balance Sheet using C# .NET Excel APIs", 400, 400);
            pic.Size.Width.Value = 400;
            pic.Size.Height.Value = 400;
            //
            doc.Body.AddParagraph("The End.");
            // Done:
            return doc;
        }
    }
}