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

Hyperlink to a page

Explorer ,
Jan 24, 2013 Jan 24, 2013

Copy link to clipboard

Copied

Hi all

I am trying to link all my images in a document.

If I recognize the filename and it is a logo (only a limited logos are present) I link to the URL

All others must link to a given page number.

The first part works. But I can not figure out how to make the link to a page...

     case "cat 22m95y v1.eps":       

            var myHyperLinkeFrame = myFrame.parent.textFrames.add(myLabelLayer2, undefined, undefined,{geometricBounds : myGreyBoxBounds});

            myHyperlinkURL = myDocument.hyperlinkURLDestinations.add("www.catfootwear.com");

            myHyperlinkSource = myDocument.hyperlinkPageItemSources.add(myHyperLinkeFrame);

            myHyperlink=myDocument.hyperlinks.add(myHyperlinkSource,myHyperlinkURL );

            myHyperlink.visible=true;                                 

    break;

    default:

            $.writeln ("myImageJumperPage " + myImageJumperPage );

            $.writeln ("myImageJumperPage " + Number (myImageJumperPage) );

            var bla = Number (myImageJumperPage) ;

            $.writeln ("bla " + bla);

            var myHyperLinkeFrame = myFrame.parent.textFrames.add(myLabelLayer2, undefined, undefined,{geometricBounds : myGreyBoxBounds});

            myHyperlinkPage = myDocument.hyperlinkPageDestinations.add();

            myHyperlinkPage.destinationPage.pageNumber = myImageJumperPage;

  

            myHyperlinkSource = myDocument.hyperlinkPageItemSources.add(myHyperLinkeFrame);

            myHyperlink=myDocument.hyperlinks.add(myHyperlinkSource, myHyperlinkPage);

            myHyperlink.visible=true;   

   

       }

Any hins appreciated

Romano

TOPICS
Scripting

Views

844

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 ,
Jan 24, 2013 Jan 24, 2013

Copy link to clipboard

Copied

should add

            myHyperlinkPage.destinationPage.pageNumber = myImageJumperPage;

this is where things go wrong...

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 ,
Jan 24, 2013 Jan 24, 2013

Copy link to clipboard

Copied

myHyperlinkPage.destinationPage = "2";

I also tried this but again no go

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
Enthusiast ,
Jan 24, 2013 Jan 24, 2013

Copy link to clipboard

Copied

Hi,

All others must link to a given page number.

it expects a whole reference.

For example:

myHyperlinkPage.destinationPage = app.activeDocument.pages.item(0)

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 ,
Jan 24, 2013 Jan 24, 2013

Copy link to clipboard

Copied

LATEST

OK I get it the reference to a page does not work based on a number as in go to page 10

Needed to create the reference in "page" terms first.

            var destPage = myDocument.pages.itemByName(myImageJumperPage.toString());

This line changes (type cast) the number to a string, then finds the page with that (String)Name and creates a reference.

I guess this could be coded in a more direct way, but I am happy.

The code does the job

Thanks for your help Hans

    case "cat 22m95y v1.eps":       

            $.writeln ("Found a logo, jump to website 2");

            var myHyperLinkeFrame = myFrame.parent.textFrames.add(myLabelLayer2, undefined, undefined,{geometricBounds : myGreyBoxBounds});

            var myHyperlinkURL = myDocument.hyperlinkURLDestinations.add("www.catfootwear.com");

            var myHyperlinkSource = myDocument.hyperlinkPageItemSources.add(myHyperLinkeFrame);

            var myHyperlink = myDocument.hyperlinks.add(myHyperlinkSource,myHyperlinkURL );

            myHyperlink.visible = true;                                 

    break;

    default:

            $.writeln ("Found any image, create link to the price list on page: " + myImageJumperPage );

            var myHyperLinkeFrame = myFrame.parent.textFrames.add(myLabelLayer2, undefined, undefined,{geometricBounds : myGreyBoxBounds});

            var destPage = myDocument.pages.itemByName(myImageJumperPage.toString());

            var myHyperlinkDestination = myMakeHyperlinkDestination(destPage, myDocument);            

  

            var myHyperlinkSource = myDocument.hyperlinkPageItemSources.add(myHyperLinkeFrame);

            var myHyperlink = myDocument.hyperlinks.add(myHyperlinkSource, myHyperlinkDestination);

            myHyperlink.visible = true;   

    }    

function myMakeHyperlinkDestination(myDestPage, myDocument){

    //If the hyperlink destination already exists, use it;

    //if it doesn't, then create it.

    try{

        var myHyperlinkDestination = myDocument.hyperlinkDestinations.item(myDestPage);

        myHyperlinkDestination.name;

    }

    catch(myError){

        myHyperlinkDestination = myDocument.hyperlinkPageDestinations.add(myDestPage);

        myHyperlinkDestination.destinationPage = myDestPage;

    }

    //myHyperlinkDestination.name = myDestPage.name;

    //Set other hyperlink properties here, if necessary.

    return myHyperlinkDestination;

}

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