Skip to content

Dynamically show or hide components ​

How to dynamically show or hide components ​

Starting in version 8.5.2, Foxit PDF SDK for Web provides three APIs—keepState, revokeKeepState, and isStateKept—to help you show or hide components at runtime. keepState is intended for application code to manage component state; the SDK does not use it internally. Today it only applies to show/hide visibility. Call show or hide first, then call keepState to lock the current visibility so the SDK does not change it at an unexpected time.

Example:

js
const redactApplyMenu = await pdfui.getComponentByName('fv--contextmenu-item-apply');

redactApplyMenu.hide(); / First hide component.
redactApplyMenu.keepState(); / Keep the current hide state of the component, which prevents the component from being showed inside the SDK.
// Revoke the keep-state when necessary.
redactApplyMenu.revokeKeepState();