Skip to main content
Zaid Al Hilali
Community Expert
Community Expert
Sep 8, 2020 1:28 PM UTC
Answered

Scripting for a PDF form

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 is closed to new replies. Start a new post to keep the conversation going.
ls_rbls
ls_rblsCorrect answer
Community Expert
Sep 8, 2020 3:18 PM UTC

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.

Technical Generalist

5 replies

ls_rbls
Community Expert
ls_rblsCommunity ExpertCorrect answer
Community Expert
Sep 8, 2020 3:18 PM UTC

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.

Translate
Technical Generalist
Zaid Al Hilali
Community Expert
Community Expert
Sep 9, 2020 9:38 AM UTC

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.

 

Translate
Participant
Sep 30, 2020 6:21 PM UTC

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,

 

Translate