How to embed video in PDF while converting from HTML to PDF

Hi, we have a usecase in which we want to embed a video in PDF while conveting from HTML to PDF. Our HTMLs files currently have ahref links which points to some videos to local disk.

I just tried Aspose.Html package and it generates from such HTML a PDF with links you can click and see a video, which works as I expected, but this doesn’t solve our problem.

What we want to achieve is to make these ahref not clickable links, but embeded videos inside PDF after the conversion from HTML to PDF. I see that using just Aspose.HTML package is not enough, please correct me if I am wrong.

Also, I saw that adding video to PDF may be achieved by using package Aspose.PDF. In general, ideal solution would be:

  1. Find HTML element by some ID
  2. Embed video as a child of this element
  3. Continue with others HTML elements
  4. Generated PDF after conversion, has all videos embeded directly in PDF file

Please indicate tools/libraries you own, with the help of which, we can achieve our goal.
Thanks in advance!

@doit34

Yes, you can create a PDF with embedded videos inside it using Aspose.PDF. It offers MovieAnnotation and RichMediaAnnotation Classes. MovieAnnotation can just play a link to the external video file (placed on disk or internet). However, RichMediaAnnotation is used to play media stored within PDF documents.

In fact, RichMediaAnnotation is a container for SWF (Flash) script. Due to license restriction, we can not include third-party flash scripts in our product, so you should provide your script for playing video or audio. For example, you can use VideoPlayer and AudioPlayer shipped with Adobe Acrobat. It is placed in the Acrobat folder Acrobat\Multimedia Skins\Players.

Would you please share your sample source HTML file (in .zip format) along with an expected output PDF? This would help us investigating the feasibility of your requirements and share our feedback with you accordingly.

@doit34

Thanks for sharing requested information in the private message.

We have tried to add a movie annotation inside sample PDF with .mkv file and noticed that it was unable to play in the resultant file. Also, no thumbnail was present in the output PDF. We used following code snippet:

Document orig = new Document();
Page lastPage = orig.Pages.Add();
MovieAnnotation mov = new MovieAnnotation(
lastPage, new Aspose.Pdf.Rectangle(4f * 72f, 3.5f * 72f, 3f * 72f, 4f * 72f), @"G:\Torrents\Trauma Center.mkv");
lastPage.Annotations.Add(mov);
orig.Save(dataDir + "MoviveAttachmentIssue.pdf");

Therefore, we have logged an issue as PDFNET-49268 in our issue tracking system to investigate the complete feasibility of this case. We will look into the details of the ticket and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

No worries at all. I am grateful for time and effort you spent to investigate and solve my case. I saw on the web that generaly things related to videos in PDF are very complicated when it comes to implementation.

Thanks!

@doit34

Thanks for your feedback.

We will surely update you in this forum thread as soon as we have some certain updates regarding the resolution of the logged ticket.