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

file name copied to text box in the form

Community Beginner ,
Jul 26, 2018 Jul 26, 2018

Copy link to clipboard

Copied

is there way to automatically bring in file name in the one of the text box in the adobe form?

sorry in advance for dump question.

example for my question.  assume file name is: "john doe (XXXX) 07.26.2018.pdf"

take the john doe (name of the file) and automatically input in to one of the text box in the form.  text box name is "name"

Please let me know and thank you for your help.  THANK YOU!

TOPICS
Acrobat SDK and JavaScript , Windows

Views

1.3K

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 , Jul 27, 2018 Jul 27, 2018

You can use this code to do it:

this.getField("Name").value = this.documentFileName.split("(")[0];

this.getField("Date").value = this.documentFileName.split(") ")[1].replace(".pdf", "");

Place these two lines of code under Tools - JavaScript - Document JavaScripts in a new item called "Scripts".

Votes

Translate

Translate
Community Expert ,
Jul 26, 2018 Jul 26, 2018

Copy link to clipboard

Copied

Add this code to a document level script.

this.getField("FileNameField").value = this.documentFileName;

Of course you'll need to add a field to the form with the name "FileNameField", or change the name in the code to match the one on your form.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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 Beginner ,
Jul 26, 2018 Jul 26, 2018

Copy link to clipboard

Copied

what do you mean by document level script?  I am very new at this and i do not know much.

thank you for your help!

Votes

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 Beginner ,
Jul 26, 2018 Jul 26, 2018

Copy link to clipboard

Copied

whenever there is change to file name or save as new file name and when file (PDF form) is open I want the data from file name to fill the two text boxes ("name" & date) in the PFD form. 

for example if the

file name is: John, Doe (1234) 07.26.2018.pdf

"Name" text box will get: John, Doe (1234)

and " Date Text box will get: 07.26.2018

if the file name is updated and/or changed to Doe, John (1234) 07.27.2018.pfd

"Name" text box will get: Doe, John (1234)

and " Date Text box will get: 07.27.2018

if this coding involves document level script please advise me how and where to do this well.

Thank you!

Votes

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 Beginner ,
Jul 27, 2018 Jul 27, 2018

Copy link to clipboard

Copied

LATEST

Thank you so much for your help.

THANK YOU!

Votes

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 ,
Jul 26, 2018 Jul 26, 2018

Copy link to clipboard

Copied

Yes, it's possible to copy the file name to a specific field, but you seem to want to do something more complicated than that.

How would the script know which part of the name to copy? Should it copy the part before a "(" (if it always exists)? Something else?

Votes

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 Beginner ,
Jul 26, 2018 Jul 26, 2018

Copy link to clipboard

Copied

Try67,  here is an example.

PDF file name is:   John Doe (1234) 07.26.2018.pdf.  there will always be file name like this.  when i open the file i want my pdf to brining the name and the date off of the PDF file name.

when i name or change or update the file name and open the file I want my pdf form to copy the file name into two text boxes.  two boxes names are:

1. "name"

2. "date"

on the "name" text box I want to bring in John Doe

and the "date" text box I want to bring in 07.26.2018 to the PDF form text box.

is this clear?  hope it helps and thank you very much for your help.

THANK YOU!

Votes

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 ,
Jul 27, 2018 Jul 27, 2018

Copy link to clipboard

Copied

You can use this code to do it:

this.getField("Name").value = this.documentFileName.split("(")[0];

this.getField("Date").value = this.documentFileName.split(") ")[1].replace(".pdf", "");

Place these two lines of code under Tools - JavaScript - Document JavaScripts in a new item called "Scripts".

Votes

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 Beginner ,
Jul 27, 2018 Jul 27, 2018

Copy link to clipboard

Copied

once again, THANK YOU SO MUCH!!!

have a nice day!!

Votes

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