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

Save PDF in Current Folder Named after Two Fields Javascript

New Here ,
Apr 06, 2018 Apr 06, 2018

Copy link to clipboard

Copied

Hello,

I have read through few discussions and can't seem to find a javascript that lets you save pdf in current folder. Everyone asks for it to be saved in a specified folder.
So, I was wondering if there is a javascript that can save the PDF in folder that the PDF is currently in named after two fields in Adobe Form.

Thanks!

TOPICS
Acrobat SDK and JavaScript , Windows

Views

242

Likes

Translate

Translate

Report

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

Community Expert , Apr 06, 2018 Apr 06, 2018

Sure, that's possible.

You can use something like this to do it:

var newFileName = this.getField("Text1").valueAsString + "-" + this.getField("Text2").valueAsString + ".pdf;

this.saveAs(this.path.replace(this.documentFileName, newFileName);

Likes

Translate

Translate
Community Expert ,
Apr 06, 2018 Apr 06, 2018

Copy link to clipboard

Copied

Sure, that's possible.

You can use something like this to do it:

var newFileName = this.getField("Text1").valueAsString + "-" + this.getField("Text2").valueAsString + ".pdf;

this.saveAs(this.path.replace(this.documentFileName, newFileName);

Likes

Translate

Translate

Report

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
New Here ,
Dec 11, 2021 Dec 11, 2021

Copy link to clipboard

Copied

This is probably a case of the carpenter blaming his tools, but I wondered has anything changed in Adobe since this answer. 

When I run it I get "NotAllowedError: Security settings prevent access to this property or method...." in the console. In addition I have  copied other scripts dealing with saving  PDFs and have frequently gotten this message.

Stay safe

Thank you. 

Likes

Translate

Translate

Report

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 ,
Dec 11, 2021 Dec 11, 2021

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

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
New Here ,
Dec 12, 2021 Dec 12, 2021

Copy link to clipboard

Copied

LATEST

Mr. Alheit

Thank you. Thank you. Thank you. I can stop butting my head against a tree

 

I have build a program (ExpungeKY.com) where users (total strangers or their lawyers) can get a form, fill it out, save it and  later use it to expunge a criminal record. If I understand you correctly, there is no realistic way for me to have the file already be named, for example, "Jones-12345" when the user saves it. 

 

A person usually needs several different forms. My biggest number has been 40, but 6-10 is not unusual. I just thought it would help the user keep things straight if the files automatically came with a unique name. Of course the user can name the file the old fshioned way-- retype it. No big deal. Just a convenience.

 

I do a fair number of these forms myself. I assume there is a way to put this feature in a separate set of forms just for use only on my own cmputer. Is that a big deal?

 

Again thanks and stay safe. If you need to charge me to answer this, let me know. Jwp@aye.net.

Likes

Translate

Translate

Report

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