Remove Open Action

Contents
[ ]

PDF documents may contain actions that execute automatically when the file is opened, such as JavaScript alerts, navigation commands, or other behaviors. In some scenarios, you may need to remove these actions for security, compliance, or user experience reasons.

Using PdfContentEditor, you can easily remove the document open action and ensure the PDF opens without executing any automatic behavior.

  1. Create the PdfContentEditor object.
  2. Bind the input PDF.
  3. Remove the Document Open Action.
  4. Save the updated 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 remove_open_action(infile, outfile):
    # Create PdfContentEditor object
    content_editor = pdf_facades.PdfContentEditor()
    # Bind document to PdfContentEditor
    content_editor.bind_pdf(infile)
    # Remove open action from the document
    content_editor.remove_document_open_action()
    # Save updated document
    content_editor.save(outfile)