file name copied to text box in the form

Community Beginner ,
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!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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".

TOPICS
Acrobat SDK and JavaScript, Windows

Views

310

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

file name copied to text box in the form

Community Beginner ,
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!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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".

TOPICS
Acrobat SDK and JavaScript, Windows

Views

311

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
Jul 26, 2018 0
Adobe Community Professional ,
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.

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
Reply
Loading...
Jul 26, 2018 0
Community Beginner ,
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!

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
Reply
Loading...
Jul 26, 2018 0
Community Beginner ,
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!

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
Reply
Loading...
Jul 26, 2018 0
ytk1978 LATEST
Community Beginner ,
Jul 27, 2018

Copy link to clipboard

Copied

Thank you so much for your help.

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
Reply
Loading...
Jul 27, 2018 0
Most Valuable Participant ,
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?

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
Reply
Loading...
Jul 26, 2018 0
Community Beginner ,
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!

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
Reply
Loading...
Jul 26, 2018 0
Most Valuable Participant ,
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".

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
Reply
Loading...
Jul 27, 2018 1
Community Beginner ,
Jul 27, 2018

Copy link to clipboard

Copied

once again, THANK YOU SO MUCH!!!

have a nice day!!

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
Reply
Loading...
Jul 27, 2018 0