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

How to add the location of a pdf file to the pdf that changes automatically if location changes like in Excel

Explorer ,
Apr 15, 2019 Apr 15, 2019

Copy link to clipboard

Copied

I have Windows 10.  In Adobe Acrobat XI Pro, is there a way to add text to a pdf file that gives the path location of the pdf file that changes automatically if the location changes-similar to what MIcrosoft Word Excel does?  Please break your answer down to very simple, easy-to follow steps.

TOPICS
Create PDFs

Views

11.4K

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 ,
Apr 16, 2019 Apr 16, 2019

Copy link to clipboard

Copied

Create a new text field. Call it "FilePath". Set it as Read-Only.

Go to Tools - JavaScript - Document JavaScripts and add a new script. Call it "load".

Delete any code that is generated automatically and replace it with this:

this.getField("FilePath").value = this.path;

Save your file. Close it and then re-open. The field should now display the current file path.

If you want the field to update when the file is re-saved (not only when it is opened) then place that code also under: Tools - JavaScript - Set Document Actions - Did Save.

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
Apr 16, 2019 Apr 16, 2019

Copy link to clipboard

Copied

Note that this solution only works for PDF renderers that support JavaScript!

          - Dov

- Dov Isaacs, former Adobe Principal Scientist (April 30, 1990 - May 30, 2021)

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
Explorer ,
Apr 17, 2019 Apr 17, 2019

Copy link to clipboard

Copied

Mr. Isaacs, thank you so much for your reply.  I worked on it.  I have not been able to "add a new text field.  How do you do that?.

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
LEGEND ,
Apr 18, 2019 Apr 18, 2019

Copy link to clipboard

Copied

Use Prepare Form in Acrobat Pro.

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
Explorer ,
Apr 22, 2019 Apr 22, 2019

Copy link to clipboard

Copied

I'm sorry.  I didn't even know how to get started on this reply.  I am a novice.

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
Explorer ,
Apr 22, 2019 Apr 22, 2019

Copy link to clipboard

Copied

I think I figured out how to create a text field.  Go to Tools-Forms-Create-Choose Create a Form from Existing File and Next.  Choose current document  and continue.  Under "ADD NEW Field"  I choose "Text Field."  I get a box with the name "Text" centered in it.  I double-click on the "Text" name and a window called "Text Field Properties" opens up.

Under the General Tab, I change the name to "Filename."  I click the read-only box.  Under the "Appearance Tab", I do add a border and different color font.  I do not check the "Locked" box in the lower left corner.  I change nothing else, and click on close.

I go back to Tools-JavaScript-Document JavaScripts and add a new script.  I call it "load".  Then I delete any code that automatically pops up in the JavaScript Editor window.  I copy and paste in getField("FilePath").value = this.path;    I click ok on the Editor window.  It adds the word "load" to the middle Document JavaScripts window and the "copy and pasted" script to the bottom of the window.

I did click on the word "load" in the middle window and the "Add" button to be sure it saved it.  Then I closed the Document JavaScript window.  My test field labeled "FilePath" is gone.  I save my file and totally close Adobe Acrobat XI Pro.  I find my file in Explore, open it, and absolutely nothing is there.

I go to Tools-Set Document Action-choose "Document Did Save" and OK.  I then tried saving the file in a different place and reopening it.  There was no file location anywhere on the document at all.

I was very careful not to add a space or use a capital letter in place of a small one and vice-versa. Would the mixup of a capital letter and a small one make a difference? I have no idea what is wrong.  I think I had one file I stumbled around with for hours, and got it to work, but now I can't remember which one it is or where it came from.

I have no idea what this means: Note that this solution only works for PDF renderers that support JavaScript!

I tried googling it and all I got was super confused.  I couldn't even figure out how you can know if your if your PDF renderers can support JavaScript.  The PDF I was working so hard on tonight was were I had converted a webpage from Chrome to a PDF file.

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 ,
Apr 22, 2019 Apr 22, 2019

Copy link to clipboard

Copied

Is the name of the field "Filename" or "FilePath" ?

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
New Here ,
May 17, 2021 May 17, 2021

Copy link to clipboard

Copied

Mr. Isaacs,

Thank you!  This solution worked for me. My filepath is a little long for the field. What would you recommend, as part of the path is cut off when I print the document. (The filepath is complete in the field, I must highlight and move to the right to view.)  Should I change the size font in the field, or change the size of the field? Not sure which to do, or how to do that.

 

Thank you!

TBowman

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
New Here ,
May 17, 2021 May 17, 2021

Copy link to clipboard

Copied

I found the solution. In my case, I needed to do both, change the font, and expand the field. Under Prepare Form, double clicked on the field to bring up Text Field Properties box, went to Appearance, changed font size, closed, then draged the box to make it as long as was needed.

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
Explorer ,
Apr 23, 2019 Apr 23, 2019

Copy link to clipboard

Copied

I am so sorry, try67.  I am so confused I was writing to Mr. Isaacs, not that I don't appreciate everyone's help.I think that Bernd Alhelt was right.  That maybe I did use the name "Filename" instead of "Filepath."  I have tried over and over again to get your steps to work, try67.  No luck.

I have no idea what these two replies mean-one from Mr. Isaacs, "Note that this solution only works for PDF renderers that support JavaScript!"   The second one is from "Test Screen Name" and says, "Use Prepare Form in Acrobat Pro."  Adobe Acrobat is my least known software.  If it is not broken down step by step, I am lost.  It took me hours and hours to figure out the steps try67 gave me.

I don't see a way to attach a pdf to this post.  I took the file I was working on, and stripped of any personal information.  Then I tried to add a link to it.  That is something else I am trying to learn to do.  The link was to this conversation.  Then I went through the steps per try67 to show how they were not working.  I was hoping someone could tell me what I was doing wrong.  The PDF was a webpage I converted to PDF.  Could that be the problem?

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 ,
May 02, 2019 May 02, 2019

Copy link to clipboard

Copied

Do you see any error message in the console?

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
New Here ,
Dec 02, 2022 Dec 02, 2022

Copy link to clipboard

Copied

Hi Try...67.! I have tried your suggested code to no avail:

My doc javascript 'load' contains:

function load()
this.getField(FilePath).value = this.path;

and my textbox 'FilePath' is read only with no javascript associated to it.

I have saved and reopened the file and also added this script to the 'Document Will Save' option.

Do these scripts automatically populate textbox 'Filepath' with the file path?

I MUST be missing something? Any ideas?

Thanks in advance.

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 ,
Dec 02, 2022 Dec 02, 2022

Copy link to clipboard

Copied

Check the JavaScript console for errors.

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
New Here ,
Dec 02, 2022 Dec 02, 2022

Copy link to clipboard

Copied

Thank You Bernd.

 

As well as seeing no errors upon writing and adding, I have ran them both through the Javascript Debugger in my Acrobat XI and as well,  neither throw an error.

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
New Here ,
Dec 02, 2022 Dec 02, 2022

Copy link to clipboard

Copied

Yes, following the direction and producing no results or errors, made me turn to this community.....as a wise cat once said..."GAK!!"

 

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 ,
Dec 02, 2022 Dec 02, 2022

Copy link to clipboard

Copied

Where does you use the function load?

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 ,
Dec 03, 2022 Dec 03, 2022

Copy link to clipboard

Copied

LATEST

FilePath must be in quotes.

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
LEGEND ,
Apr 23, 2019 Apr 23, 2019

Copy link to clipboard

Copied

Taking two of these points:

> I have no idea what these two replies mean-one from Mr. Isaacs,

>"Note that this solution only works for PDF renderers that support JavaScript!"

There is now a LOT of PDF reading software. As well as the Adobe software, there are Google Chrome, Microsoft Edge, FireFox, and the PDF readers built into phones and tablets. Most of these do NOT work with JavaScript, so any attempt to do clever stuff just won't work. If you're doing this for yourself, it may be fine. If you're doing it for other people, you can find things very difficult.

>  The second one is from "Test Screen Name" and says, "Use Prepare Form in Acrobat Pro."

>Adobe Acrobat is my least known software.

Sorry, wrong advice. You're using very old software, and Prepare Form is in the current version, Acrobat DC. Basically you go into creating or editing forms, which is different in every version to keep us on our toes!

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
Explorer ,
Apr 23, 2019 Apr 23, 2019

Copy link to clipboard

Copied

Thanks

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 ,
Apr 23, 2019 Apr 23, 2019

Copy link to clipboard

Copied

If you're still unable to do it share your file via Dropbox, Google Drive, Adobe DC, etc., and I'll do it for 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
Explorer ,
May 01, 2019 May 01, 2019

Copy link to clipboard

Copied

Thanks, I really appreciate the offer.  But that wouldn't show me how to do it.

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 ,
May 02, 2019 May 02, 2019

Copy link to clipboard

Copied

I've explained how to do it...

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