Renaming a PDF file using data from PDF form
Copy link to clipboard
Copied
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.
 
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
Copy link to clipboard
Copied
Have you checked this tutorial yet:

