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

Hyperlink Creation for Images

Participant ,
Mar 18, 2020 Mar 18, 2020

Copy link to clipboard

Copied

Hi,

I have run the script to allocate the hyperlink to the images but it won't work. After running this script I had export the INDD file to PDF .In that PDF there is no link present.I have attached the sample script 

 

 


// One document open
// Hyperlinks not necessarily labeled by character style
// You want all hyperlinks to be live
// Typesetter sometimes inserts a space or return in middle of URL to force a line break
// Space or return comes before period or slash per style manual

var doc=app.activeDocument;

// Compress stray www .'s
fn_grepChange (doc, "www(\\s|\\n)\\.", "www.");
// Normalize to http://
fn_grepChange (doc, "(http\\:\\/\\/)?(www\\.([\\w\\-\\?\\=\\&]+[\\.\\/]?)+)", "http://$2");
// Remove ( space or return ) before ( period or slash )
fn_grepChange (doc, "(http\\:\\/\\/([\\w\\-\\?\\=\\&]+[\\.\\/]?)+)(\\s|\\n)(\\.|\\/)", "$1$4");

// ---- Main ---- //
app.changeGrepPreferences = NothingEnum.nothing;
app.findGrepPreferences = NothingEnum.nothing;
app.findChangeGrepOptions.includeFootnotes = true;

// Regardless of character styles, find hyperlinks
app.findGrepPreferences.findWhat = 'http\\:\\/\\/([\\w\\-\\?\\=\\&]+[\\.\\/]?)+';

var found = app.findGrep();
alert(found)
var report = "found and activated "+String(found.length)+" links\n";
alert(report)
// make hyperlinks

for(i=0; i<found.length; i++)
{
var report = report+found[i].contents+"\n";
try
{
var source = doc.hyperlinkTextSources.add(found[i]);
var dest=doc.hyperlinkURLDestinations.add(found[i].contents);

doc.hyperlinks.add(source,dest, {visible:false, name:found[i].contents+"("+(i+1)+")"});
}
catch(e)
{}
}

// If exporting to PDF set include hyperlinks to true
PDFExportPreset.includeHyperlinks = true;
// To export to html, choose File-->Export for Dreamweaver

app.changeGrepPreferences = NothingEnum.nothing;
app.findGrepPreferences = NothingEnum.nothing;

//alert ( report );

function fn_grepChange (myDocument, regexFind, regexChange) {
// purpose: execute a grep change, otherwise known as a regex s///;
//Initialize.
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;

//Set the find options.
app.findChangeGrepOptions.includeFootnotes = true;
app.findChangeGrepOptions.includeHiddenLayers = false;
app.findChangeGrepOptions.includeLockedLayersForFind = false;
app.findChangeGrepOptions.includeLockedStoriesForFind = false;
app.findChangeGrepOptions.includeMasterPages = false;

//Search and change
app.findGrepPreferences.findWhat = regexFind;
app.changeGrepPreferences.changeTo = regexChange;
myDocument.changeGrep();

//Clear the find/change preferences.
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;
}

// --- end of script --- //

 

Please do guide on this script....

-Monisha
TOPICS
How to , Scripting , SDK

Views

898

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

correct answers 1 Correct answer

Participant , May 11, 2020 May 11, 2020

Hi all,

I find out the solution for my query.  Thank you for all who replies me

Votes

Translate

Translate
Community Expert ,
Mar 18, 2020 Mar 18, 2020

Copy link to clipboard

Copied

Hi,

 

Can I check that the hyperlinks windows has new links created after your script has run?

If I get a chance later I will try and run your code.

 

Regards

Malcolm

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
Participant ,
Mar 18, 2020 Mar 18, 2020

Copy link to clipboard

Copied

Hi i had export the indesign document as a PDF format in that i wont get the desired output.I have attached the exported pdf for your refereence1.png

-Monisha

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 ,
Mar 19, 2020 Mar 19, 2020

Copy link to clipboard

Copied

I would take a look at this line: 

 


PDFExportPreset.includeHyperlinks = true;

 

What preset are you using. Let's say it's called myPreset. You would want to do: 

 

app.PDFExportPresets.itemByName("myPreset"). includeHyperlinks = true; 

 

I also don't see where you're using the script to call the export. If you manually run an export without a preset, and check the Include Hyperlinks button, do they appear?

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
Participant ,
Mar 19, 2020 Mar 19, 2020

Copy link to clipboard

Copied

Hi,

 

It shows an error in the folloing line

error.png

-Monisha

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
Participant ,
May 11, 2020 May 11, 2020

Copy link to clipboard

Copied

LATEST

Hi all,

I find out the solution for my query.  Thank you for all who replies me

-Monisha

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