How to Create a PDF Button That Opens the Save As Dialog
Question details
The user wants to configure an interactive button within a PDF document to trigger a Save As dialog for a specific linked file.

- Product
- Device & OS
- not provided
- Scenario
- Adding interactive form buttons to a PDF document to allow users to easily download or save linked resources, such as embedded attachments or online files.
- Observed behavior
- PDF readers typically block arbitrary file saving due to JavaScript security restrictions, requiring specific workflows based on whether the file is an attachment, local, or hosted online.
Before adding interactive buttons, determine the exact location of the file you want to link (whether it is an embedded attachment, a local system file, or hosted online), as modern PDF security policies strictly limit how external files can be saved.
Extract an Embedded Attachment via JavaScript
If the file is embedded within the PDF as an attachment, you can use a JavaScript action on the button to prompt the user with a Save As dialog.
Because PDF viewers prevent scripts from silently downloading external files, embedding the file directly into the PDF document is the most reliable way to ensure the Save As dialog functions correctly across different devices.
Open the Attachments panel in your PDF editor and add the file you wish to make available for download.
Select the Button tool from the form editing menu and draw a button on your document page.
Right-click the newly created button, select 'Properties', and navigate to the 'Actions' tab.
Choose 'Run a JavaScript' from the action dropdown and click 'Add'.
Type 'this.exportDataObject({ cName: "your-filename.ext", nLaunch: 0 });' into the editor, replacing 'your-filename.ext' with the exact name of your attached file, then click 'OK'.

Link to a Hosted Online File
For files hosted online, the most secure and universally supported method is to configure the button to open a web link, allowing the web browser to handle the download prompt.
Easily Edit PDFs and Add Interactive Links with WPS Office
WPS Office provides a comprehensive PDF editor that allows you to easily insert links, manage attachments, and configure interactive document elements without complex scripting.
- 1. Open your document: Launch WPS Office and open the PDF file you wish to modify.
- 2. Access editing tools: Navigate to the 'Edit' tab located on the top ribbon.
- 3. Insert a link: Click on 'Link' and draw a rectangle over the text or image you want to make clickable.
- 4. Configure the destination: Choose whether the link should direct to a web page or open a local file, set the path, and save your document.

Frequently Asked Questions
Why doesn't the Save As dialog appear when I click my PDF button?
Modern PDF viewers implement strict security restrictions on JavaScript to prevent malicious downloads. Scripts attempting to silently save arbitrary external files will be blocked. To fix this, you must use supported methods like the exportDataObject function for files already attached to the document.
Can a PDF button save a file directly to a local drive without prompting the user?
No. For security reasons, standard PDF readers require a user-initiated Save As dialog to prevent unauthorized files from being secretly downloaded and saved to your computer.
How do I attach a file to my PDF before linking it to a button?
In your PDF editor, locate the 'Attachments' panel, which is typically represented by a paperclip icon on the sidebar. Click 'Add Attachment' to embed the file directly into the document, making it accessible for JavaScript extraction commands.
Does WPS Office support adding interactive links to PDFs?
Yes, WPS Office PDF Editor supports viewing interactive documents and allows you to easily add hyperlinks that direct users to web pages, jump to specific pages within the document, or open external files.




