Fix PDF JavaScript Email Submission Failing in Online Viewers
Question details
The user needs to resolve an issue where an interactive PDF order form fails to attach the document or populate email fields when using an online PDF viewer.

- Product
- Device & OS
- not provided
- Scenario
- A user is trying to submit a completed PDF order form directly via email using an embedded JavaScript 'mailDoc' button.
- Observed behavior
- The JavaScript email function works perfectly in desktop Adobe Reader but fails entirely in online browser-based PDF viewers, losing both recipient information and the file attachment.
Verify whether the issue occurs consistently across different web browsers (such as Chrome, Edge, and Safari) to confirm it is a general viewer limitation rather than a temporary browser glitch, and ensure you have a desktop PDF reader available for testing.
Require Users to Open the PDF in a Desktop Reader
Because browser viewers restrict advanced JavaScript APIs like mailDoc for security reasons, advising users to download the file and open it in a dedicated desktop application is the most reliable workaround.
Modern browser-based PDF viewers lack support for full Acrobat JavaScript APIs. They intentionally restrict automated email generation and background file attachments to prevent malicious activity or spam.
To ensure the form works as intended, users must interact with the document outside of the browser ecosystem.
Include clear, bold text at the top of your PDF or on the webpage hosting the file stating: 'For the submit button to work correctly, please download this file and open it in a desktop PDF reader.'
Instruct the user to right-click the PDF link on your website and select 'Save link as...' or 'Download linked file' to save the document directly to their computer.
Have the user launch their desktop PDF application (such as WPS PDF or Adobe Reader) and open the downloaded form to successfully use the interactive email submission button.

Provide a Manual Download and Email Option
Offer an alternative manual submission method for users who cannot or prefer not to install a desktop PDF reader.
Replace the PDF with a Server-Side Web Form
If direct browser submission is strictly required by your business process, transitioning from a PDF file to an HTML web form ensures maximum compatibility.
Easily Fill and Share PDF Forms with WPS PDF
WPS Office includes a powerful desktop PDF editor that flawlessly handles fillable forms. Bypass frustrating browser restrictions by using WPS PDF to fill out your order forms and share them via email in just a few clicks.
- 1. Download and Install WPS Office: Download WPS Office from the official website and install it on your PC or Mac to access the dedicated WPS PDF desktop application.
- 2. Open and Fill the PDF Form: Launch WPS PDF and open your interactive PDF order form. Fill in your details smoothly without encountering browser-based script limitations.
- 3. Share via Email: Click the 'Share' or 'Email' button in the top toolbar to automatically attach the completed PDF to your system's default email client.

Frequently Asked Questions
Why does the mailDoc function work in Adobe Reader but not in Chrome or Edge?
Desktop applications like Adobe Reader have deep integration with your operating system's default email clients and support the full Acrobat JavaScript API. In contrast, web browsers use built-in, lightweight PDF viewers that intentionally restrict these APIs for security reasons, preventing malicious scripts from automatically drafting emails or attaching files.
Is there a JavaScript alternative to mailDoc that works in web browsers?
No, standard PDF JavaScript APIs for email routing will not bypass browser security models. If you need a fully browser-compatible automated solution, you must host a web form (HTML) and use server-side scripts (such as PHP or Python) to handle the email transmission securely.
Can I force a browser to open my PDF in a desktop viewer?
You cannot force this behavior universally through website code, as it depends entirely on the user's individual browser settings. However, you can advise your users to configure their browser to 'Always download PDF files' instead of opening them in a new tab.
Does WPS Office support filling out interactive PDF forms?
Yes, the WPS PDF desktop application supports reading and filling out standard interactive PDF forms. Users can complete their forms locally and use the built-in sharing features to email the document securely without relying on complicated JavaScript code.




