Highlighted

Hyperlink Creation for Images

Explorer ,
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

Hi all,

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

TOPICS
How to, Scripting, SDK

Views

598

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

Hyperlink Creation for Images

Explorer ,
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

Hi all,

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

TOPICS
How to, Scripting, SDK

Views

599

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
Mar 18, 2020 0
Adobe Community Professional ,
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

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...
Mar 18, 2020 0
Explorer ,
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

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...
Mar 18, 2020 0
Adobe Community Professional ,
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?

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

Copy link to clipboard

Copied

Hi,

 

It shows an error in the folloing line

error.png

-Monisha

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...
Mar 19, 2020 0
Explorer ,
May 11, 2020

Copy link to clipboard

Copied

Hi all,

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

-Monisha

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