Highlighted

How to change automatically frame with hyperlink text into hyperlinked frame

New Here ,
Apr 19, 2019

Copy link to clipboard

Copied

I have an hyperlinks in text frames, different in each frame, and I want to have, a link with url to the frames no to text only.
Is it possible to make this automatically in whole document?

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

Try the following code, it will remove hyperlink on a text and make a hyperlink on its parent textframe with the same destination URL. The code works on the assumption that a textframe will have only one text hyperlink

var h = app.documents[0].hyperlinks.everyItem().getElements()

for(var i = 0; i < h.length; i++)

{

    if(h.source.constructor.name != "HyperlinkTextSource")

          continue;

    var pt = h.source.sourceText.parentTextFrames[0]

    var nm = h.name

    var newSource = app.documents[0].hyperlinkPageItemSources.add(pt)

    var nh = app.documents[0].hyperlinks.add(newSource, h.destination)

    h.remove()

    nh.name = nm

}

-Manan

TOPICS
Scripting

Views

412

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

How to change automatically frame with hyperlink text into hyperlinked frame

New Here ,
Apr 19, 2019

Copy link to clipboard

Copied

I have an hyperlinks in text frames, different in each frame, and I want to have, a link with url to the frames no to text only.
Is it possible to make this automatically in whole document?

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

Try the following code, it will remove hyperlink on a text and make a hyperlink on its parent textframe with the same destination URL. The code works on the assumption that a textframe will have only one text hyperlink

var h = app.documents[0].hyperlinks.everyItem().getElements()

for(var i = 0; i < h.length; i++)

{

    if(h.source.constructor.name != "HyperlinkTextSource")

          continue;

    var pt = h.source.sourceText.parentTextFrames[0]

    var nm = h.name

    var newSource = app.documents[0].hyperlinkPageItemSources.add(pt)

    var nh = app.documents[0].hyperlinks.add(newSource, h.destination)

    h.remove()

    nh.name = nm

}

-Manan

TOPICS
Scripting

Views

413

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
Apr 19, 2019 0
Adobe Community Professional ,
Apr 19, 2019

Copy link to clipboard

Copied

Try the following code, it will remove hyperlink on a text and make a hyperlink on its parent textframe with the same destination URL. The code works on the assumption that a textframe will have only one text hyperlink

var h = app.documents[0].hyperlinks.everyItem().getElements()

for(var i = 0; i < h.length; i++)

{

    if(h.source.constructor.name != "HyperlinkTextSource")

          continue;

    var pt = h.source.sourceText.parentTextFrames[0]

    var nm = h.name

    var newSource = app.documents[0].hyperlinkPageItemSources.add(pt)

    var nh = app.documents[0].hyperlinks.add(newSource, h.destination)

    h.remove()

    nh.name = nm

}

-Manan

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...
Apr 19, 2019 1
New Here ,
Apr 23, 2019

Copy link to clipboard

Copied

Well Done! Works fine! Thanks a lot

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