Add Movie Annotation

Contents
[ ]

Movie annotations in PDFs allow you to embed multimedia content, such as videos, into your documents. Using PdfContentEditor, you can define a rectangle on a page where the video will appear. When clicked, the video can be played directly from the PDF, making your documents more interactive and engaging.

  1. Create a PdfContentEditor instance.
  2. Bind the input PDF document.
  3. Define a rectangle for the movie annotation.
  4. Specifie the video file to embed.
  5. Assign the page number for the annotation.
  6. Save the updated PDF document.
import aspose.pdf.facades as pdf_facades
import aspose.pydrawing as apd
import sys
from os import path

sys.path.append(path.join(path.dirname(__file__), ".."))

from config import set_license, initialize_data_dir


def add_movie_annotation(infile, movie_file, outfile):
    # Create PdfContentEditor object
    content_editor = pdf_facades.PdfContentEditor()
    # Bind document to PdfContentEditor
    content_editor.bind_pdf(infile)
    # Add movie annotation to page 1
    content_editor.create_movie(apd.Rectangle(80, 500, 220, 120), movie_file, 1)
    # Save updated document
    content_editor.save(outfile)