addLink is not defined error

New Here ,
Aug 16, 2018

Copy link to clipboard

Copied

I'm creating a feature in acrobat reader to navigate to a web page when certain words are clicked.

I'm using the 'addLink' function to do it by referring the book 'Developing Acrobat Applications using Javascript' but I'm getting the error 'addLink is not defined'

Please help with possible solutions

Thanks in advance

TOPICS
Acrobat SDK and JavaScript

Views

663

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

addLink is not defined error

New Here ,
Aug 16, 2018

Copy link to clipboard

Copied

I'm creating a feature in acrobat reader to navigate to a web page when certain words are clicked.

I'm using the 'addLink' function to do it by referring the book 'Developing Acrobat Applications using Javascript' but I'm getting the error 'addLink is not defined'

Please help with possible solutions

Thanks in advance

TOPICS
Acrobat SDK and JavaScript

Views

664

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
Aug 16, 2018 0
Adobe Community Professional ,
Aug 16, 2018

Copy link to clipboard

Copied

Use Adobe Acrobat, not Acrobat Reader.

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...
Aug 16, 2018 0
New Here ,
Aug 16, 2018

Copy link to clipboard

Copied

I'm using adobe acrobat pro dc..even then I'm getting the error

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...
Aug 16, 2018 0
Adobe Community Professional ,
Aug 16, 2018

Copy link to clipboard

Copied

Post the Code. May be we can help you.

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...
Aug 16, 2018 0
New Here ,
Aug 16, 2018

Copy link to clipboard

Copied

if ( typeof sdkMenuItem == "undefined")

var sdkMenuItem = false;

if (!sdkMenuItem) {

sdkMenuItem = true;

app.addSubMenu( {

cName:"ACROSDK:JSSubMenu",

cUser: "Acrobat SDK JavaScript",

cParent: "Edit",

nPos: 0

});

}

// add a menu item  to extract text.

app.addMenuItem(  { 

cName: "ACROSDK:AddLinks",  

cUser: "Add links to retrieve partNo info ...",  

cParent: "ACROSDK:JSSubMenu",

cEnable: "event.rc = (event.target != null);", 

cExec: "AddLinks();"

}); 

function AddLinks() 

try  {

var p=this.pageNum;

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.adobe.com/products/acrobat', false);");

}

}

} catch (e)  { 

app.alert(e)

}; 

}

I need to somewhat tweak the logic based on the my requirement but my intention is same as in the code

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...
Aug 16, 2018 0
Adobe Community Professional ,
Aug 16, 2018

Copy link to clipboard

Copied

Try:

this.addLink( ...);

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...
Aug 16, 2018 0
New Here ,
Aug 16, 2018

Copy link to clipboard

Copied

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...
Aug 16, 2018 0
Most Valuable Participant ,
Aug 16, 2018

Copy link to clipboard

Copied

The code works fine for me, although I agree that adding "this." before addLink is a good idea.

I would also drop the try-catch clause, so you could see the full error message in the console.

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...
Aug 16, 2018 0
Most Valuable Participant ,
Aug 16, 2018

Copy link to clipboard

Copied

Why are you using getURL? That attempts to convert the web-page into a PDF, which won't work in Reader, for example.

If you just want to display that web-page then use app.launchURL("http://..."), instead.

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...
Aug 16, 2018 0
New Here ,
Aug 16, 2018

Copy link to clipboard

Copied

Thanks! It worked

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...
Aug 16, 2018 0
New Here ,
Aug 19, 2018

Copy link to clipboard

Copied

Is there any alternative for 'addLink' function to use in adobe reader?

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...
Aug 19, 2018 0
Adobe Community Professional ,
Aug 19, 2018

Copy link to clipboard

Copied

Acrobat Reader can't add links.

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...
Aug 19, 2018 0
New Here ,
Aug 19, 2018

Copy link to clipboard

Copied

I have created a feature in acrobat dc pro to navigate to a web page using addLink function in javascript.I want to push this feature in adobe reader but when it is executing,I'm getting 'NotAllowedError:Security settings prevent access to this property or method'

What are the steps for pushing the feature to 'Reader' which was developed in 'Acrobat pro'

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...
Aug 19, 2018 0
Most Valuable Participant ,
Aug 20, 2018

Copy link to clipboard

Copied

None. It can't be achieved in Reader. Nor do I see why you would need to.

Create the file in Acrobat, add the links to it, and then distribute it to the users. The links you created will work in Reader. They don't need to be added there.

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...
Aug 20, 2018 0
New Here ,
Aug 20, 2018

Copy link to clipboard

Copied

I enabled the feature in acrobat and saved the document.When I opened the saved document using reader,the link is not redirecting to the required page.

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...
Aug 20, 2018 0
Adobe Community Professional ,
Aug 20, 2018

Copy link to clipboard

Copied

What kind of link?

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...
Aug 20, 2018 0
Most Valuable Participant ,
Aug 20, 2018

Copy link to clipboard

Copied

As I told you earlier, the getURL method won't work in Reader.

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...
Aug 20, 2018 0
New Here ,
Aug 20, 2018

Copy link to clipboard

Copied

The hyperlink created using 'addLink' function in javascript

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...
Aug 20, 2018 0
New Here ,
Aug 20, 2018

Copy link to clipboard

Copied

I'm not using getURL method,launchURL method is used for navigation

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...
Aug 20, 2018 0
Most Valuable Participant ,
Aug 20, 2018

Copy link to clipboard

Copied

OK, so what happens when you click the link, exactly?

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...
Aug 20, 2018 0
New Here ,
Aug 20, 2018

Copy link to clipboard

Copied

The links do exist but no action is getting performed

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...
Aug 20, 2018 0
Most Valuable Participant ,
Aug 20, 2018

Copy link to clipboard

Copied

Can you share a sample page with some links (via Dropbox, Google Drive, Adobe Send & Track, etc.)?

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...
Aug 20, 2018 0
Adobe Community Professional ,
Aug 20, 2018

Copy link to clipboard

Copied

Can you share a sample file?

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...
Aug 20, 2018 0
New Here ,
Aug 20, 2018

Copy link to clipboard

Copied

I have shared a sample doc which you access through the dropbox 840190-0000revA-SHT1 (2)

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...
Aug 20, 2018 0
Adobe Community Professional ,
Aug 20, 2018

Copy link to clipboard

Copied

It is not possible to access this link.

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...
Aug 20, 2018 0
New Here ,
Aug 20, 2018

Copy link to clipboard

Copied

Please use this link Dropbox - sampledoc.pdf

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...
Aug 20, 2018 0
Adobe Community Professional ,
Aug 20, 2018

Copy link to clipboard

Copied

Using the link I get following error:

ReferenceError: newWord is not defined

1:Link:Mouse Up

Where did you set this variable?

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...
Aug 20, 2018 0
New Here ,
Aug 20, 2018

Copy link to clipboard

Copied

Please have a look at the script which I'm using Dropbox - script.js

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...
Aug 20, 2018 0
Most Valuable Participant ,
Aug 20, 2018

Copy link to clipboard

Copied

This is not the script you used on the sample file you shared, because the link is not the same.

Post your actual code, please.

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...
Aug 20, 2018 0
New Here ,
Aug 20, 2018

Copy link to clipboard

Copied

I have changed the link alone.Sorry for the change!!

The link is confidential

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...
Aug 20, 2018 0
Most Valuable Participant ,
Aug 20, 2018

Copy link to clipboard

Copied

Why did you include a variable in it, and where is that variable defined?

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...
Aug 20, 2018 0
New Here ,
Aug 20, 2018

Copy link to clipboard

Copied

The 'newWord' is the variable and it is defined in the line

var nextWord = this.getPageNthWord(p, i+1, false);

The variable was included in the url to navigate to the web page based on the value of the variable

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...
Aug 20, 2018 0
New Here ,
Aug 20, 2018

Copy link to clipboard

Copied

SorryIt is defined here,

newWord = ckWord.concat(nextWord);

should I add 'var' before it? Is that a mistake?

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...
Aug 20, 2018 0
Most Valuable Participant ,
Aug 20, 2018

Copy link to clipboard

Copied

Yes, that's better, but it's not the issue.

You need to include the actual value of that variable when you set the link, but include a reference to it.

If you post your actual code (just the line that sets the link's action is enough) we could help you change it.

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...
Aug 20, 2018 0
New Here ,
Aug 20, 2018

Copy link to clipboard

Copied

I don't know what is wrong suddenly.I was not getting that error.Let me try that from my side

The actual issue for me is that 'addLink' is not working at the reader side even if the pdf is saved by adding links in the acrobat

Please give your help for this issue

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...
Aug 20, 2018 0
Most Valuable Participant ,
Aug 20, 2018

Copy link to clipboard

Copied

We did, but you're not making it easier because you're not providing us with the correct code you're using.

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...
Aug 20, 2018 0
Most Valuable Participant ,
Aug 16, 2018

Copy link to clipboard

Copied

[Question moved to the JavaScript forum]

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...
Aug 16, 2018 0