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

addLink is not defined error

New Here ,
Aug 16, 2018 Aug 16, 2018

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
2.7K
Translate
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 ,
Aug 16, 2018 Aug 16, 2018

Use Adobe Acrobat, not Acrobat Reader.

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

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

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

Post the Code. May be we can help you.

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

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

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

Try:

this.addLink( ...);

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

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.

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

Thanks! It worked

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

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.

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

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

Translate
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 ,
Aug 19, 2018 Aug 19, 2018

Acrobat Reader can't add links.

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

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'

Translate
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 ,
Aug 20, 2018 Aug 20, 2018

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.

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

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.

Translate
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 ,
Aug 20, 2018 Aug 20, 2018

What kind of link?

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

The hyperlink created using 'addLink' function in javascript

Translate
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 ,
Aug 20, 2018 Aug 20, 2018

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

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

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

Translate
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 ,
Aug 20, 2018 Aug 20, 2018

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

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

The links do exist but no action is getting performed

Translate
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 ,
Aug 20, 2018 Aug 20, 2018

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

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

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

Translate
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 ,
Aug 20, 2018 Aug 20, 2018

It is not possible to access this link.

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

Please use this link Dropbox - sampledoc.pdf

Translate
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