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

Hide Navigation if no bookmarks available though javascript action

Community Beginner ,
Jul 08, 2020 Jul 08, 2020

Copy link to clipboard

Copied

I want to hide Navigation panel if there is no bookmarks are available.
I tried using create new action and execute javascript code:

function HideNavigation(bm){

	if (bm == null) {
		this.viewState = {overViewMode:1}
	}
	return;
}

HideNavigation(this.bookmarkRoot.children);

Action runs perfectly and I saved the file but once I reopen the document still it shows Navigation.
Any idea to resolve the issue ?

TOPICS
Acrobat SDK and JavaScript

Views

267

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 ,
Jul 08, 2020 Jul 08, 2020

Copy link to clipboard

Copied

Where did you place the code, exactly?

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 Beginner ,
Jul 08, 2020 Jul 08, 2020

Copy link to clipboard

Copied

In Adobe acrobat pro I created a action and by using option 'Exceute Javascript' I have added code in that.

 

action.PNG

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 ,
Jul 08, 2020 Jul 08, 2020

Copy link to clipboard

Copied

Actions only execute when you, well, execute them... If you want the code to run when the file is opened you have to embed it in it. Go to Tools - JavaScript - Document JavaScripts and place your code there.

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 Beginner ,
Jul 08, 2020 Jul 08, 2020

Copy link to clipboard

Copied

Yes I did executed Action and saved the file. I want this operation to execute for multiple files within same folder because of that I created Action.

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 ,
Jul 08, 2020 Jul 08, 2020

Copy link to clipboard

Copied

OK, then you need to create an Action that embeds this code in the files you're running it on, not execute it directly... You can do it like this (I'm using my more simplified version of your code from below):

 

this.addScript("nav", "if (this.bookmarkRoot.children == null) this.viewState = {overViewMode:1};");

 

Don't forget to add a step to save the files, too.

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 ,
Jul 08, 2020 Jul 08, 2020

Copy link to clipboard

Copied

PS. Your code is unnecessarily complicated. You can replace it with this single line:

 

if (this.bookmarkRoot.children == null) this.viewState = {overViewMode:1};

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 Beginner ,
Jul 08, 2020 Jul 08, 2020

Copy link to clipboard

Copied

Yes, That I can update once I get concrete soultion and reason for the issue.

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 ,
Jul 08, 2020 Jul 08, 2020

Copy link to clipboard

Copied

LATEST

You can also use

 this.pane="N";

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