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

SAVING A SPACE IN FILE NAME

Community Beginner ,
Oct 20, 2018 Oct 20, 2018

Javascript newbie here,,,and thanks in advance for any help.

I am simply trying to add a couple of spaces when using a javascript to save a file. The file is an employment application which is named "Phoenix Employment Packet.pdf"  When an applicant presses the SAVE button, I would like the saved file to go into a specified network folder with a new filename using the "last name" and "first name" fields of the form.

Everything seems to be working fine, except I cannot get it to save WITH spaces. For example: Fred Smith fills it out and saves. The resulting file name is: smithfredapplication.pdf   instead of:  smith fred application.pdf.  or even better yet, smith, fred application.pdf.

Here is my code. Any help is greatly appreciated.

this.saveAs("/c/APPTESTFILE/" + this.getField("lastname").value + "" + this.getField("firstname").value + "" + "application.pdf");

Oh...running Adobe Acrobat Pro DC no Win10 64bit

TOPICS
Acrobat SDK and JavaScript , Windows
1.3K
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

correct answers 1 Correct answer

LEGEND , Oct 20, 2018 Oct 20, 2018

Every place you want to add a blank space, replace "" with " ". You should also get the field values using the valueAsString property. So the entire line of code should be:

this.saveAs("/c/APPTESTFILE/" + this.getField("lastname").valueAsString + " " + this.getField("firstname").valueAsString + " " + "application.pdf");

Note that this won't work in a button action unless the document has a certification signature and the user chooses to trust it to allow privileged JavaScript. It will work in the

...
Translate
LEGEND ,
Oct 20, 2018 Oct 20, 2018

Every place you want to add a blank space, replace "" with " ". You should also get the field values using the valueAsString property. So the entire line of code should be:

this.saveAs("/c/APPTESTFILE/" + this.getField("lastname").valueAsString + " " + this.getField("firstname").valueAsString + " " + "application.pdf");

Note that this won't work in a button action unless the document has a certification signature and the user chooses to trust it to allow privileged JavaScript. It will work in the interactive JavaScript console, which you can use for testing. For more information, see: https://acrobatusers.com/tutorials/how-save-pdf-acrobat-javascript

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 Beginner ,
Oct 20, 2018 Oct 20, 2018
LATEST

Thank you SO much!! Works perfectly!

[Edited by Moderator]

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