Pdf Component - PdfHideAction

18 Nov 20263 minutes to read

Represents an action that hides or shows one or more form fields or annotations.

// Create a new PDF document
let document: PdfDocument = new PdfDocument();
let page: PdfPage = document.addPage();
// Create a text box field
let textField: PdfTextBoxField = new PdfTextBoxField(
    page, 'CustomerName', { x: 20, y: 20, width: 150, height: 30 }
);
document.form.add(textField);
// Create a Hide Action
let action: PdfHideAction = new PdfHideAction(true, [
    { fieldName: 'CustomerName' }
]);
// Create a button and assign the action
let button: PdfButtonField = new PdfButtonField(
    page, 'HideCustomerName', { x: 20, y: 70, width: 120, height: 30 }
);
button.text = 'Hide targets';
button.actions.mouseUp = action;
document.form.add(button);
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();

Properties

Get hide boolean

Gets whether the targets are hidden.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Get the Hide Action
let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
let action: PdfHideAction = field.actions.mouseUp as PdfHideAction;
// Get the visibility state
let hide: boolean = action.hide;
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();

Set hide void

Sets whether the targets are hidden.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Get the Hide Action
let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
let action: PdfHideAction = field.actions.mouseUp as PdfHideAction;
// Show the targets
action.hide = false;
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();
Parameter Type Description
value boolean true to hide the targets; false to show them.

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 targets PdfHideTargetCollection

Gets the collection of form-field and annotation targets associated with the Hide Action.

// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Get the Hide Action
let field: PdfButtonField = document.form.fieldAt(0) as PdfButtonField;
let action: PdfHideAction = field.actions.mouseUp as PdfHideAction;
// Get the target collection
let targets: PdfHideTargetCollection = action.targets;
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();