Add Movie Annotation
Contents
[
Hide
]
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.
- Create a PdfContentEditor instance.
- Bind the input PDF document.
- Define a rectangle for the movie annotation.
- Specifie the video file to embed.
- Assign the page number for the annotation.
- 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)