Pdf - PdfRichMediaCommand

18 Nov 20264 minutes to read

Represents a command executed by a rich-media annotation.

// Load an existing PDF document containing a rich-media annotation
let document: PdfDocument = new PdfDocument(data, password);
let page: PdfPage = document.getPage(0);
// Get the existing rich-media annotation
let annotation: PdfRichMediaAnnotation = page.annotations.at(0) as PdfRichMediaAnnotation;
// Create a rich-media command
let command: PdfRichMediaCommand = new PdfRichMediaCommand('play');
command.arguments = [0];
// Create a rich-media execute action
let action: PdfRichMediaExecuteAction = new PdfRichMediaExecuteAction(annotation, command);
// Create a button and assign the action
let field: PdfButtonField = new PdfButtonField(
    page, 'ExecuteRichMedia', { x: 20, y: 20, width: 140, height: 30 }
);
field.actions.mouseUp = action;
document.form.add(field);
// Save and destroy the document
document.save('output.pdf');
document.destroy();

Properties

Get arguments Array

Gets the arguments passed to the rich-media command.

// Load an existing PDF document containing a rich-media execute action
let document: PdfDocument = new PdfDocument(data, password);
let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
// Get the rich-media execute action
let action: PdfRichMediaExecuteAction = field.actions.mouseUp as PdfRichMediaExecuteAction;
// Get the rich-media command arguments
let argumentsValue: Array<string | number | boolean> = action.command.arguments;
// Save and destroy the document
document.save('output.pdf');
document.destroy();

Set arguments void

Sets the arguments passed to the rich-media command.

// Load an existing PDF document containing a rich-media execute action
let document: PdfDocument = new PdfDocument(data, password);
let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
// Get the rich-media execute action
let action: PdfRichMediaExecuteAction = field.actions.mouseUp as PdfRichMediaExecuteAction;
// Set the rich-media command arguments
action.command.arguments = [0, true];
// Save and destroy the document
document.save('output.pdf');
document.destroy();
Parameter Type Description
value Array The arguments to pass to the command.

Get command string

Gets the command executed by the rich-media instance.

// Load an existing PDF document containing a rich-media execute action
let document: PdfDocument = new PdfDocument(data, password);
let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
// Get the rich-media execute action
let action: PdfRichMediaExecuteAction = field.actions.mouseUp as PdfRichMediaExecuteAction;
// Get the rich-media command
let command: string = action.command.command;
// Save and destroy the document
document.save('output.pdf');
document.destroy();

Set command void

Sets the command executed by the rich-media instance.

// Load an existing PDF document containing a rich-media execute action
let document: PdfDocument = new PdfDocument(data, password);
let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
// Get the rich-media execute action
let action: PdfRichMediaExecuteAction = field.actions.mouseUp as PdfRichMediaExecuteAction;
// Set the rich-media command
action.command.command = 'pause';
// Save and destroy the document
document.save('output.pdf');
document.destroy();
Parameter Type Description
value string The command to execute.