Skip to main content
Zaid Al Hilali
Community Expert
Community Expert
September 8, 2020
Answered

Scripting for a PDF form

  • September 8, 2020
  • 1 reply
  • 1076 views

Since I couldn't find the Acrobat scripting forum which used to exist, I had to post my question here.

 

I have a simple PDF form which will be filled by users. At the bottom of the form, I placed a "Send" button that will automatically attach the PDF to the email and will eventually be sent to the concerned person.

Is there a way to have the Entity Name (see image) show in the e-Mail Subject instead of having the document name?

 

This topic has been closed for replies.
Correct answer ls_rbls

Acrobat SDK and JavaScript, is the right support forum for what your asking.

 

You'll probably looking into using the mailDoc() method.

 

Here's a sample script that I used to help  another user recently:

 

var cFromAddr =  this.getField("Email").value;

var cToAddr = "myemail@company.com";

var cSubLine = "I, " + this.getField("Name").value +", " + "want to buy a car from " + this.getField("Range_From").value +" range at a " + this.getField("Range_To").value +" rate." ;

var cBody = "In here is the message body which you can customize and add other text fields as shown in the subject line above." + "\n \nPlease send this email to yourself by clicking the Submit button above,  review the terms in this form and save it for your files."

this.mailDoc({bUI: true, cTo: cToAddr, cFromAddr: cFromAddr, cSubject: cSubLine, cMsg: cBody});

 

I adapted the script with ideas of other users who have posted similar questions and using as a guideline the examples provided in the Adobe Acrobat SDK JavaScript API Reference,  Doc methods, page 287.

1 reply

ls_rbls
Community Expert
ls_rblsCommunity ExpertCorrect answer
Community Expert
September 8, 2020

Acrobat SDK and JavaScript, is the right support forum for what your asking.

 

You'll probably looking into using the mailDoc() method.

 

Here's a sample script that I used to help  another user recently:

 

var cFromAddr =  this.getField("Email").value;

var cToAddr = "myemail@company.com";

var cSubLine = "I, " + this.getField("Name").value +", " + "want to buy a car from " + this.getField("Range_From").value +" range at a " + this.getField("Range_To").value +" rate." ;

var cBody = "In here is the message body which you can customize and add other text fields as shown in the subject line above." + "\n \nPlease send this email to yourself by clicking the Submit button above,  review the terms in this form and save it for your files."

this.mailDoc({bUI: true, cTo: cToAddr, cFromAddr: cFromAddr, cSubject: cSubLine, cMsg: cBody});

 

I adapted the script with ideas of other users who have posted similar questions and using as a guideline the examples provided in the Adobe Acrobat SDK JavaScript API Reference,  Doc methods, page 287.

Zaid Al Hilali
Community Expert
Community Expert
September 9, 2020

Good day, 

Thank you so much for sharing the script with me. I sat today with my colleague, made necessary changes to your script to suit our needs.

Here is what we used at the end…

var cToAddr = "email1@domain.com";

var cCCAddr = "email2@domain.com";

var cSubLine = "True-up Request for: " + this.getField("entity_name").value + ", Ref. No.: " + this.getField("entity_reference").value;

 

var cBody = "The attached file contains data that was entered into a form. It is not the form itself." + "\n \nThe recipient of this data file should save it locally with a unique name. Adobe Acrobat Professional 7 or later can process this data by importing it back into the blank form or creating a spreadsheet from several data files. See Help in Adobe Acrobat Professional 7 or later for more details.";

 

this.mailDoc({bUI: true, cTo: cToAddr, cCc: cCCAddr, cSubject: cSubLine, cMsg: cBody});

 

Just to explain the script for other readers. Press the send button in the pdf form will attach the full pdf to an email for the sender.

Two-persons will receive an email that shows the following in the subject box: Entity Name, and Reference.

 

Participant
September 30, 2020

Hey, looking for this solution too. Can you tell me where in the PDF you added the code to?

 

Button Properties / Actions / ??

 

Can you provide a screenshot?

 

Thanks,