添加电影批注

Contents
[ ]

PDF 中的电影批注允许您将多媒体内容(例如视频)嵌入文档中。使用 PdfContentEditor,您可以在页面上定义一个矩形区域,以显示视频。单击后,视频可直接从 PDF 播放,使您的文档更具交互性和吸引力。

  1. 创建一个 PdfContentEditor 实例。
  2. 绑定输入的 PDF 文档。
  3. 定义一个用于电影注释的矩形。
  4. 指定要嵌入的视频文件。
  5. 为注释指定页码。
  6. 保存更新后的 PDF 文档。
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)