PDF Editing Issues

How to Create a PDF Button That Opens the Save As Dialog

Jason MillerJason Miller Nov 3, 2026 869 views

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.

Create a PDF Button That Opens the Save As Dialog
Product
PDF
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 you start

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.

Solution 1Recommended

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.

1
Attach the file

Open the Attachments panel in your PDF editor and add the file you wish to make available for download.

2
Create a form button

Select the Button tool from the form editing menu and draw a button on your document page.

3
Access button properties

Right-click the newly created button, select 'Properties', and navigate to the 'Actions' tab.

4
Add a JavaScript action

Choose 'Run a JavaScript' from the action dropdown and click 'Add'.

5
Enter the script

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'.

Extract an Embedded Attachment via JavaScript
Security Restrictions: Modern PDF viewers restrict silent saving. The exportDataObject method respects these security boundaries by forcing the system Save As dialog to open, ensuring the user maintains control over where the file is stored.

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. 1. Open your document: Launch WPS Office and open the PDF file you wish to modify.
  2. 2. Access editing tools: Navigate to the 'Edit' tab located on the top ribbon.
  3. 3. Insert a link: Click on 'Link' and draw a rectangle over the text or image you want to make clickable.
  4. 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.
Easily add and edit hyperlinks to local files or online resourcesFully compatible with standard PDF formats and Adobe Acrobat featuresLightweight, fast, and user-friendly interface for seamless document editingFree tools to view, merge, split, and annotate PDF documents
microsoft office alternative - wps office

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.