PDF Editing Issues

How to Save, Compress, and Email a PDF Form Using an Acrobat Button

Muhammad TalhaMuhammad Talha Nov 5, 2026 869 views

Question details

The user needs an Acrobat form button to automatically compress/optimize a PDF file before saving and emailing it, circumventing JavaScript security restrictions.

How to Save, Compress, and Email a PDF Form via a Button in Acrobat
Product
Adobe Acrobat XI Pro
Device & OS
not provided
Scenario
Automating document workflows within an interactive PDF form to ensure files are reduced in size before being sent to recipients.
Observed behavior
The current button successfully saves and emails the PDF, but cannot execute file compression directly due to Acrobat JavaScript limitations without a trusted context.
Before you start

Before modifying your PDF, ensure you have administrative access to Acrobat Pro to create application-level JavaScripts and a basic understanding of Acrobat's Preflight tools.

Solution 1Recommended

Use a Custom Preflight Profile and Application-Level Script

Configure a custom Preflight profile to handle the optimization, and execute it via an application-level trusted script to bypass security prompts for saving and emailing.

Standard document-level JavaScript cannot perform silent saves or file optimizations due to inherent security protocols. To accomplish this, the optimization must be handled by Acrobat's Preflight tool, and the script triggering it must be elevated to a 'trusted context' by placing it in the application's JavaScripts folder.

1
Create a Custom Preflight Profile

Navigate to 'Tools' > 'Print Production' > 'Preflight' in Acrobat Pro. Create a new custom profile specifically designed to optimize and compress PDF files, and note its exact name.

2
Write the Application-Level Script

Create a new .js file in the Acrobat application JavaScripts directory (e.g., C:\Program Files (x86)\Adobe\Acrobat\Acrobat\JavaScripts). Define a function using 'app.trustedFunction' to elevate its privileges.

3
Invoke Preflight via JavaScript

Inside your trusted function, use the Document object's 'preflight' method to call the custom profile you created, applying the optimization to the active document.

4
Save and Email the Optimized PDF

Add commands within the trusted function to silently save the file using the 'saveAs' method, followed by the 'mailDoc' method to attach the newly compressed file to an email draft.

5
Link the Script to the Form Button

Open your PDF form in Edit mode, right-click the button, select 'Properties', go to the 'Actions' tab, and add a 'Run a JavaScript' action that simply calls the trusted function you defined.

Use a Custom Preflight Profile and Application-Level Script
Script Deployment: Because the trusted script resides in the application folder, this solution requires the script to be installed locally on every user's computer who clicks the form button.

Compress and Share PDFs Instantly with WPS Office

If setting up application-level scripts and trusted functions is too complex, WPS Office provides built-in tools to easily compress your PDFs and share them via email without writing a single line of code.

  1. 1. Open your PDF: Launch WPS Office and open the PDF document you want to compress and send.
  2. 2. Compress the Document: Navigate to the 'Tools' tab on the top ribbon and click on 'Compress' to easily reduce the file size.
  3. 3. Share via Email: Click the 'Menu' icon in the top left corner, hover over 'Share', and select 'Email' to instantly attach your optimized PDF to a new message.
No complex JavaScript or trusted folder setup requiredFully compatible with standard PDF and Microsoft Office formatsBuilt-in, one-click document compression toolSeamless email integration for instant sharing
microsoft office alternative - wps office

Frequently Asked Questions

Why can't a standard PDF button script automatically compress files?

Acrobat's JavaScript security model restricts actions like silent saving and system-level file optimization to protect users from malicious code execution. These actions require a 'trusted context' to bypass user prompts.

Where do I place a trusted application-level script in Acrobat?

Application-level scripts must be saved as a .js file and placed in the application's root JavaScripts folder, typically located at C:\Program Files (x86)\Adobe\Acrobat\Acrobat\JavaScripts on Windows.

Can I email a PDF without saving it first?

You can email the current unsaved state of a PDF using standard mailDoc scripts. However, if you need to apply Preflight optimization, you must save the document to lock in the compression before attaching it.

How do I reduce PDF file size manually without scripting?

You can manually reduce file size in Acrobat by navigating to 'File' > 'Save As Other' > 'Reduced Size PDF', or by using the intuitive 'Compress' tool found in the Tools tab of WPS Office.