Is there a way to add video?

Hello,
Is there a way to add a video to the document?

I thought it would be the same concept as adding images but apparently, it’s not, and seems that we are missing headers or we get an error overloaded parameters…

Kind regards,

Hi Raymond,

I presume you’re referring to the “Online Videos” action from Microsoft Word.
Unfortunately, GemBox.Document currently doesn’t have API support for it.

Regarding the missing headers, please send us a snippet code that demonstrates what you’re doing so that we can take a look at it.

Regards,
Mario

That is a bummer. It’s one of those essential elements that we really need to complete our project.
I would say about 70% of the documents that we get now have video and 90% in a .pdf

I’ve been playing around with different ways into doing this task.
Here are my workarounds:

  1. Get the thumbnail image of the video
  2. Convert the image to a link

When this is accomplished, your computer will open the default browser and play the video.

The downfall is that the documents that we would create aren’t at a professional level. What we are technically force doing now is create the document and then open it and insert the video manually. In our productivity environment this can take a half hour to do and with multiple documents customized for our clients can take all day for 20+ docs. At this point, this approach is unproductive.

GemBox Document is for the most part an awesome tool to have. The one thing that we needed to finish our programming experiment is missing.
Are there any development updates to when GemBox is going to provide video?

We hope sooner than later…

Raymond, can you clarify something for me, are you looking to have those embedded fonts in DOCX or in PDF?

Note that we’re currently investigating this feature and if it’s possible to provide something right away, but only for DOCX files.

Can you please send us a sample DOCX file that you want to create? We’ll use it for testing purposes.

Hi Mario,

We would like to use both word and PDF, but in that case HTML should work as well considering this would be an online video.
Here is an example link: Upload files for free - testVideo.docx - ufile.io

I’m thinking if we can get the Word DOCX to do video, we can always open the Word doc and Save As a .pdf for the conversion.

So in a nutshell, our documents that we are currently putting together now are at minimum of 60+ pages that include several of photos and a handful of videos explaining home inspections to our clients.

Also, if and when you convert this Word document to a PDF and click on the video, it will open your default browser. The video will be opened in “oembed” in full-screen regardless of where you get your videos from (YouTube, Vimeo, etc…)

Hi Raymond,

Please try again with this bugfix:
https://www.gemboxsoftware.com/document/nightlybuilds/GBD35v1280.zip

Or this NuGet package:
Install-Package GemBox.Document -Version 35.0.1280-hotfix

And try running the following example:

var document = new DocumentModel();

var section = new Section(document);
document.Sections.Add(section);

var paragraph = new Paragraph(document);
section.Blocks.Add(paragraph);

var picture = new Picture(document, "image1.jpeg", 12.75, 7.17, LengthUnit.Centimeter)
{
    OnlineVideo = new OnlineVideo("""<iframe src="https://player.vimeo.com/video/153180331?h=f9c02fe856&app_id=122963" width="640" height="360" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen="" title="Home Inspection Training Home Inspection Podcast January 2016" sandbox="allow-scripts allow-same-origin allow-popups"></iframe>""", 640, 360)
};
// Specify metadata. This is optional.
picture.Metadata.Name = "Video 1";
picture.Metadata.Description = "www.icaschool.com In our January Home Inspection Podcast, Steve responds to a question from Tom in Orlando Florida. Tom asks about how to deal with competition in the home inspection industry. If you have any questions or topics that you might want Steve to cover in a future Home Inspection Podcast, just email those to podcast@icaschool.com.";
// Add picture under the hyperlink. The hyperlink is used in output PDF because PDF doesn't support embedding online videos.
var hyperlink = new Hyperlink(document, "https://player.vimeo.com/video/153180331?h=f9c02fe856&app_id=122963", picture);

paragraph.Inlines.Add(hyperlink);

paragraph = new Paragraph(document);
section.Blocks.Add(paragraph);

picture = new Picture(document, "image2.jpg", 12.7, 9.53, LengthUnit.Centimeter)
{
    OnlineVideo = new OnlineVideo("""<iframe width="200" height="113" src="https://www.youtube.com/embed/3FXGXqIghFc?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="" title="Performing a Home Inspection with InterNACHI® Certified Professional Inspector CPI® Jim Krumm." sandbox="allow-scripts allow-same-origin allow-popups"></iframe>""", 200, 113)
};
// Specify metadata. This is optional.
picture.Metadata.Name = "Video 2";
picture.Metadata.Description = "Performing a Home Inspection with InterNACHI® Certified Professional Inspector CPI® Jim Krumm.";
// Add picture under the hyperlink. The hyperlink is used in output PDF because PDF doesn't support embedding online videos.
hyperlink = new Hyperlink(document, "https://www.youtube.com/embed/3FXGXqIghFc?feature=oembed", picture);

paragraph.Inlines.Add(hyperlink);

// Set compatibility mode to 15 or higher so that MS Word is able to playback the video.
document.Settings.CompatibilityMode = 15;

document.Save("testVideoGemBox.docx");
document.Save("testVideoGemBox.pdf");
document.Save("testVideoGemBox.html", new HtmlSaveOptions() { EmbedOnlineVideos = true });

Does this solve your issue?

Regards,
Mario

Hi Mario,

Awesome work! :slight_smile: I checked over the code and looks like everything is in-place for the code to work. However, I’m unable to test the code via the NuGet due to the latest build is still the version 35.0.1265.

When downloading the latest build, works perfect for C# but getting build errors in vb net. So I will continue to play with the vb net aspect, considering it was the deciding factor for this project to be written in vb net…

But overall, great job! I’m still at aww on the fast the turn around time to get this add-on function for the consumer product. The one thing that we needed to get our project up and running quickly and to meet the demands of the overall project. Thank you…

We’ve clearly decided to side on GemBox for our preferred components.

Hi Raymond,

Note that this build is available on NuGet as well, it’s a hidden pre-released version.
In order to install it you’ll need to use that provided command on the Package Manager Console in Visual Studio.

Also, here is a VB.NET version of the same code:

Dim document As New DocumentModel()
Dim section As New Section(document)
document.Sections.Add(section)

Dim paragraph = New Paragraph(document)
section.Blocks.Add(paragraph)

Dim picture = New Picture(document, "image1.jpeg", 12.75, 7.17, LengthUnit.Centimeter) With
{
    .OnlineVideo = New OnlineVideo("<iframe src=""https://player.vimeo.com/video/153180331?h=f9c02fe856&app_id=122963"" width=""640"" height=""360"" frameborder=""0"" allow=""autoplay; fullscreen; picture-in-picture"" allowfullscreen="""" title=""Home Inspection Training Home Inspection Podcast January 2016"" sandbox=""allow-scripts allow-same-origin allow-popups""></iframe>", 640, 360)
}
picture.Metadata.Name = "Video 1"
picture.Metadata.Description = "www.icaschool.com In our January Home Inspection Podcast, Steve responds to a question from Tom in Orlando Florida. Tom asks about how to deal with competition in the home inspection industry. If you have any questions or topics that you might want Steve to cover in a future Home Inspection Podcast, just email those to podcast@icaschool.com."

Dim hyperlink = New Hyperlink(document, "https://player.vimeo.com/video/153180331?h=f9c02fe856&app_id=122963", picture)
paragraph.Inlines.Add(hyperlink)

paragraph = New Paragraph(document)
section.Blocks.Add(paragraph)

picture = New Picture(document, "image2.jpeg", 12.7, 9.53, LengthUnit.Centimeter) With
{
    .OnlineVideo = New OnlineVideo("<iframe width=""200"" height=""113"" src=""https://www.youtube.com/embed/3FXGXqIghFc?feature=oembed"" frameborder=""0"" allow=""accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"" allowfullscreen="""" title=""Performing a Home Inspection with InterNACHI® Certified Professional Inspector CPI® Jim Krumm."" sandbox=""allow-scripts allow-same-origin allow-popups""></iframe>", 200, 113)
}
picture.Metadata.Name = "Video 2"
picture.Metadata.Description = "Performing a Home Inspection with InterNACHI® Certified Professional Inspector CPI® Jim Krumm."

hyperlink = New Hyperlink(document, "https://www.youtube.com/embed/3FXGXqIghFc?feature=oembed", picture)
paragraph.Inlines.Add(hyperlink)

document.Settings.CompatibilityMode = 15

document.Save("testVideoGemBox.docx")
document.Save("testVideoGemBox.pdf")
document.Save("testVideoGemBox.html", New HtmlSaveOptions() With {.EmbedOnlineVideos = True})

Regards,
Mario