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

Script to create hyperlink based on text to link to a local document

Community Beginner ,
Jan 20, 2023 Jan 20, 2023

I want a script that would create a hyperlink based on local file names, search the document for each file name, and link it to "[file name].pdf". For example, as a footnote in the pdf, it would say "document1" and "docment2"."document1.pdf" and "document2.pdf" exist in the same folder. I want the script to search for the name of each document in turn, and in the link address just add ".pdf" to the end to hyperlink it.

 

Is this possible, and if so where could I find more info on how to do this?

 

Thanks very much!

TOPICS
How to , JavaScript
1.6K
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
1 ACCEPTED SOLUTION
Community Expert ,
Jan 20, 2023 Jan 20, 2023
LATEST

The script can be set to read the contents of that file automatically (if it's location is known, and if the script runs from a privileged context, such as a folder-level file) and use it when searching the file.

This is not a trivial task by any means, though, especially if the file-names can contain more than one word.
I've developed similar tools for my clients in the past, so if you're interested in hiring a professional to create it for you, feel free to contact me privately by clicking my user-name and then on "Send a Message".

View solution in original post

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 Expert ,
Jan 20, 2023 Jan 20, 2023

You can only do it if the other files are also PDFs. However, how would the script know which texts are names of files, and which ones are just other words?

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 ,
Jan 20, 2023 Jan 20, 2023

All good for the pdfs - all docs will be pdfs. The script would need to take the name of each file in turn in the folder, search the document for that name, and where it finds that name, hyperlink it to [pdf name].pdf

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 Expert ,
Jan 20, 2023 Jan 20, 2023

That's not possible. A script in Acrobat can't access the contents of a folder. You will need to do that yourself (this is easily done using the command-line console) and then either copy & paste it into the script or read it from a text file.

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 ,
Jan 20, 2023 Jan 20, 2023

Ah, I see thank you. If I put all of the names of the pdfs in a text file, how would I incorporate that into the Adobe script without editing the script itself each time to include the specific pdf names?

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 Expert ,
Jan 20, 2023 Jan 20, 2023
LATEST

The script can be set to read the contents of that file automatically (if it's location is known, and if the script runs from a privileged context, such as a folder-level file) and use it when searching the file.

This is not a trivial task by any means, though, especially if the file-names can contain more than one word.
I've developed similar tools for my clients in the past, so if you're interested in hiring a professional to create it for you, feel free to contact me privately by clicking my user-name and then on "Send a Message".

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