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, PDF forms

Views

70

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
community guidelines
Most Valuable Participant ,
Jul 08, 2020 Jul 08, 2020

Copy link to clipboard

Copied

Where did you place the code, 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
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

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
community guidelines
Most Valuable Participant ,
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.

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
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.

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
community guidelines
Most Valuable Participant ,
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.

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
community guidelines
Most Valuable Participant ,
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};

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
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.

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
community guidelines
Adobe Community Professional ,
Jul 08, 2020 Jul 08, 2020

Copy link to clipboard

Copied

LATEST

You can also use

 this.pane="N";

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
community guidelines