Pdf Component - PdfUriAction

18 Nov 20264 minutes to read

Represents an action that opens a URI.

// Create a new PDF document
let document: PdfDocument = new PdfDocument();
let page: PdfPage = document.addPage();
// Create a URI action
let action: PdfUriAction = new PdfUriAction('https://www.example.com');
// Create a button and assign the action
let field: PdfButtonField = new PdfButtonField(
    page, 'OpenUri', { x: 20, y: 20, width: 120, height: 30 }
);
field.text = 'Open website';
field.actions.mouseUp = action;
document.form.add(field);
// Save and destroy the document
document.save('output.pdf');
document.destroy();

Properties

Get isMap boolean

Gets whether the URI is interpreted as an image map.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Get the URI button
let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
// Get the URI action and image-map setting
let action: PdfUriAction = field.actions.mouseUp as PdfUriAction;
let isMap: boolean = action.isMap;
// Save and destroy the document
document.save('output.pdf');
document.destroy();

Set isMap void

Sets whether the URI is interpreted as an image map.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Get the URI button
let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
// Get the URI action and enable the image-map setting
let action: PdfUriAction = field.actions.mouseUp as PdfUriAction;
action.isMap = true;
// Save and destroy the document
document.save('output.pdf');
document.destroy();
Parameter Type Description
value boolean true to interpret the URI as an image map; otherwise, false.

Get next PdfAction

Get the next action to be performed after the action represented by this instance.

Set next void

Set the next action to be performed after the action represented by this instance.

Parameter Type Description
value PdfAction The next action to be executed.

Get uri string

Gets the URI opened by the action.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Get the URI button
let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
// Get the URI action and URI
let action: PdfUriAction = field.actions.mouseUp as PdfUriAction;
let uri: string = action.uri;
// Save and destroy the document
document.save('output.pdf');
document.destroy();

Set uri void

Sets the URI opened by the action.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Get the URI button
let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
// Get the URI action and set the URI
let action: PdfUriAction = field.actions.mouseUp as PdfUriAction;
action.uri = 'https://www.example.com/updated';
// Save and destroy the document
document.save('output.pdf');
document.destroy();
Parameter Type Description
value string The URI to open.