Avatar

Level 4

The form has a Print button and already has this javascript xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 1, 0, 0, 0);

How do I add the following javascript to the same button and its click event?

newDocName = "";
f1 = this.getField("topmostSubform[0].Page1[0].Last_Name[0]").valueAsString;
if (f1!="") newDocName += f1 + " ";
f2 = this.getField("topmostSubform[0].Page1[0].First_Name[0]").valueAsString;
if (f2!="") newDocName += f2 + " ";
f3 = this.getField("topmostSubform[0].Page1[0].Date[0]").valueAsString;
if (f3!="") newDocName += f3 + " ";
f4 = this.getField("topmostSubform[0].Page1[0].Email[0]").valueAsString;
if (f4!="") newDocName += f4;

newDocName = newDocName.replace(/[\\,\/,\:,\*,\?,\",\<,\>,\|,\,,\n,\r]/g,"");

docPath = this.path+"";
docPath = docPath.substring(0, docPath.lastIndexOf("/")+1);

mySaveAs(this,docPath+newDocName+".pdf");

I had this working in Acrobat on an earlier version of the same form (with an external script also in the Acrobat directory -- so it all worked perfectly as a trusted function), but on this form, I don't have full access. My only option is to try to add this javascript to save the file with a new filename by using LiveCycle.