Skip to main content
Participant
October 4, 2023
Answered

Adobe Acrobat Pro - Javascript

  • October 4, 2023
  • 2 replies
  • 1320 views

Hello, I have an editable PDF form that I wish to add a button that will send via email a copy of the pdf document, but as a read only only, while keeping my official form as editable.  I only want the pdf attached in the email to be read only as to prevent recipient from editing the form.  I also want to add the document file name as the subject line in the email.  I've tried many things but I have not been able to resolve.  Seeking help here!  Thank you in advance.

This topic has been closed for replies.
Correct answer Thom Parker

So to be clear, you want the fields in the form to be set to readonly before the document is submitted, but then converted back to editable after the submit? 

 

Ok, add this script to the MouseUp on submit button before submit action

for(var i=0;i<this.numFields;i++)
   this.getField(this.getNthFieldName(i)).readonly = true;

 

Add this code after the submit actions:

for(var i=0;i<this.numFields;i++)
   this.getField(this.getNthFieldName(i)).readonly = false;

 

 

Now about setting a custom subject line. That has to be done with a script.

See this article:

https://acrobatusers.com/tutorials/dynamically-setting-submit-e-mail-address/

 

2 replies

JR Boulay
Community Expert
Community Expert
October 5, 2023

"I also want to add the document file name as the subject line in the email."

 

this.mailDoc({cTo: "contact@example.org", cSubject: this.documentFileName});

Acrobate du PDF, InDesigner et Photoshopographe
Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
October 4, 2023

So to be clear, you want the fields in the form to be set to readonly before the document is submitted, but then converted back to editable after the submit? 

 

Ok, add this script to the MouseUp on submit button before submit action

for(var i=0;i<this.numFields;i++)
   this.getField(this.getNthFieldName(i)).readonly = true;

 

Add this code after the submit actions:

for(var i=0;i<this.numFields;i++)
   this.getField(this.getNthFieldName(i)).readonly = false;

 

 

Now about setting a custom subject line. That has to be done with a script.

See this article:

https://acrobatusers.com/tutorials/dynamically-setting-submit-e-mail-address/

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
October 12, 2023

Thank you, worked great, I added a javascript in the middle of those 2 to generate the email