Control file downloads in PDF Viewer
13 Feb 20261 minute to read
Use the downloadStart event to intercept the start of a viewer download and optionally cancel it. Set args.cancel = true in the event handler to prevent the download.
- Include the JavaScript PDF Viewer script and the
Download/Toolbarmodules if the download feature is used. - Ensure the viewer instance is initialized before assigning the
downloadStarthandler.
pdfviewer.downloadStart = args => {
// Apply custom logic here
args.cancel = true; // Prevent the download action
};By default, args.cancel is false, so the download proceeds unless explicitly canceled.
Flexibility
Leverage the downloadStart event to apply custom rules for allowing or preventing downloads based on application logic.