Skip to main content
Participant
May 25, 2017
Question

I want to have a Save button on a form that saves the pdf based on what is in some fields.

  • May 25, 2017
  • 1 reply
  • 422 views

I want to have a Save button on a form that saves the pdf based on what is in some fields. I would like  the button removed from the saved pdf. I'm a Javascript newbie and I need to know where is the appropriate place to put the script to generate the file path (field, folder, document, etc.).

I'm also not sure the file path will be created properly as it doesn't pass the field values with the debugger.

var d = new Date();

var text1 = this.getField("NCMN");

var text2 = this.getField("CLASSLOT");

var text3 = this.getField("PO");

event.value = "/septaad1.org/shares/OPS_VehEng_Quality/NCMN/" + d.getFullYear() + "/NCMN_" + text1 + "_" + text2 + "_" + text3 + "_" + (d.getMonth() + 1) + "-" + d.getUTCDate() + "-" + (d.getFullYear().toString().substr(-2)) + ".pdf";

This topic has been closed for replies.

1 reply

Inspiring
May 25, 2017

I would have added the script to the "Mouse Up" action for the button and because of security restrictions in performing the "saveAs()" method of the document object. I would have had to add a folder level JavaScript to either the app JavaScript folder or the user JavaScript file for Acrobat and Reader.

I think you should read How to Save a PDF with Acrobat JavaScript by Thom Parker

RossGAuthor
Participant
May 25, 2017

Thanks for the quick reply. I have read the article mentioned. I need two other issues with script answered:

Can the button be made to disappear after the initial saveas?

Please help with the conversion of field entries to text for use in the filename.