Skip to main content
Known Participant
July 6, 2020
Question

Is there a way to automatically convert links from "open a web link" to "open a file"?

  • July 6, 2020
  • 3 replies
  • 7672 views

We create web links in a document in FrameMaker, and then save the FM document to PDF. After opening the file in Acrobat, we have to change all the "open a web link" hyperlinks to "open a file." (FrameMaker's open a file option only allows for other FM documents.) I was hoping to find an action we could run in Acrobat that uses regex to find and change the links rather than doing each one manually. Is such a thing possible? Thank you.

This topic has been closed for replies.

3 replies

ls_rbls
Community Expert
Community Expert
July 7, 2020

Does it have to be using Regex exclusively?

 

Adobe Acrobat can convert all hyperlinks automatically if:

 

  • You go to EDIT -->>PREFERENCES--->>GENERAL. In the Basic Tools section there's a tick-box "Create links from URL's"
  • NOTE: This works as long as the content of your document is entirely based on plain text. The content can't be encoded, nor be rendered text that was produced via OCR software and layered on top of a scanned image.
  • And the text string must be FreeType fonts and the URL type must also conform to this format "https://www.website.com" for example.
  • If the URLs are missig  that convention (or schema), such as missing the "www" portion  it may not detect the URLs and has to be done manually (alse evaluate what happens and how the link would behave if it detects that such links points to a local file)
  • If you don't have this setting enabled, then enable it it in the preferences and save the document and close Acrobat.
  • When you re-open the PDF in Acrobat you should notice, that even when the content appears as plain text, when the user hovers the mouse pointer over the URL text string, the mouse pointer will turn into the little hand pointing with index finger icon, and also a tooltip yellow banner will pop(visually indicating that TEXT/ HTML conversion tool place) and therefore, clicking on it will take you to that web page.

 

With those notes in mind, I have to ask, Are you saying that if you have this preference setting enabled it doesn't convert the hyperlinks automaticaly when you open the document in Acrobat?

 

In my slide below, I just copied this part of my conversion as text using the Edit PDF tool, or just by right-clickng on tmy document and selecting "Edit Text" or "Edit Text & Images".  After pasting my text selection, I saved the PDF and closed Acrobat.

 

The slide below shows the final result after I reopened the document. Hovering the mouse pointer over that string of text reveals that it is now a URL:

 

 

In addition, if I were you, instead of saving from FrameMaker to PDF directly, I would rather save your FrameMaker documents to something like Postscript format.

 

Then open that Postscript file in Adobe Acrobat so it can convert it automatically to PDF and see if in the process of doing this it automatically converts those strings of text to URL automatically.

 

Say, if this works for you, then yes, you can create a javascript action (not using Regex, of course) using a for loop to get all the  URLs  in the document and change their appearance; or even play around with the scripting to set the launching action of all the URLs found.

 

See Example 2  for "addLink" of the Adobe Acrobat SDK JavaScript API Reference, Doc methods, page 232

 

 

 

for (var p = 0; p < this.numPages; p++)
{
var numWords = this.getPageNumWords(p);
for (var i=0; i<numWords; i++)
{
var ckWord = this.getPageNthWord(p, i, true);
if ( ckWord == "Acrobat")
{
var q = this.getPageNthWordQuads(p, i);
// Convert quads in default user space to rotated
// User space used by Links.
m = (new Matrix2D).fromRotated(this,p);
mInv = m.invert()
r = mInv.transform(q)
r=r.toString()
r = r.split(",");
l = addLink(p, [r[4], r[5], r[2], r[3]]);
l.borderColor = color.red;
l.borderWidth = 1;
l.setAction("this.getURL('http://www.example.com/')");
}
}
}

 

 

 

Bernd Alheit
Community Expert
Community Expert
July 7, 2020

The OP wants file open links, not web links.

try67
Community Expert
Community Expert
July 7, 2020

Those are not even web-links, they are JS commands...

try67
Community Expert
Community Expert
July 6, 2020

It's not possible within Acrobat to automate it (maybe with a plugin...), but it is with a standalone tool.
I've developed similar tools for my clients in the past and will be happy to create one for you, too. You can contact me privately via [try6767 at gmail.com] to discuss it further, including the price.

Bernd Alheit
Community Expert
Community Expert
July 6, 2020

There is no such action in Adobe Acrobat.