• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Scripting for a PDF form

Community Expert ,
Sep 08, 2020 Sep 08, 2020

Copy link to clipboard

Copied

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?

Entity-name.jpg

 

TOPICS
Acrobat SDK and JavaScript

Views

575

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 08, 2020 Sep 08, 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
...

Votes

Translate

Translate
Community Expert ,
Sep 08, 2020 Sep 08, 2020

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 09, 2020 Sep 09, 2020

Copy link to clipboard

Copied

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.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 30, 2020 Sep 30, 2020

Copy link to clipboard

Copied

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,

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 30, 2020 Sep 30, 2020

Copy link to clipboard

Copied

Yes, this script is perfect for a MouseUp on a button. 

For further info on setting email parameters, read this article, it includes sample PDF forms. 

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

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 30, 2020 Sep 30, 2020

Copy link to clipboard

Copied

LATEST

We placed the javascript in the "Send" button

java-pane.jpg

Paste the script in the pop-up Javascript Editor that will show when you select "Run a JavaScript" option from the "Select Action" drop menu.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines