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

Renaming a PDF file using data from PDF form

Contributor ,
Sep 06, 2022 Sep 06, 2022

Hi,

A complete novice at this.

 

I've created a PDF form and I'm using a button with a Jscript to allow the user to send the completed form via mailto. 

 

With some reading, I've figured out how to get the email subject to be data from the form, but I can't figure out how to have the email attached PDF be renamed to match the subject of the email.  IE, rename the PDF to the same variable that is used to subject the email.  rather than having the PDF named the same as the form's original name I want it to be named "location-username-eventdate"  similar to the subject shown in the attached picture.  I'm guessing that including the date might be tricky.

 

adobe-pdf.jpgexpand image

 

 

My script: is largely stolen from reading other posts.

-------------------------------------------------------------

var customSubject = this.getField("Lookout").value + "-" + this.getField("Your Name").value + "-" + this.getField("Start of Shift").value;
var mailtoUrl = "mailto:marv@hestonphoto.com?subject=" + customSubject;
this.submitForm({
cURL: mailtoUrl, bPDF: true
});

var myfilename = this.getField("Lookout").value + "-" + this.getField("Your Name").value + "-" + this.getField("Start of Shift").value + "-" + ".pdf";
this.saveAs (this.path.replace(thisdocumentfilename, myfilename));

-------------------------------------------

Would someone be kind enough to push me over the hill?

 

I am just a volunteer in a non-profit forest service organization so my knowledge of writing scripts is 0 zero zippo.

 

Thanks

Marv

 

TOPICS
JavaScript , PDF forms
437
Translate
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 06, 2022 Sep 06, 2022
LATEST
Translate
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