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

How to write a simple JScript to modify bookmarks.

New Here ,
Apr 02, 2017 Apr 02, 2017

Copy link to clipboard

Copied

I want to modify the book marks in my pdf. How can I write a code in JSCript for that ?

For example when I Ctrl + J and try to run this code:

var bkm = this.bookmarkRoot.children[0];

console.println( "Top-level bookmark name: " + bkm.name );

It says :

ReferenceError: bkm is not defined

1:Console:Exec

undefined

Thanks for your kind assistance.

Message was edited by: JSM (Discussion successfully moved from The Lounge to Editing & Exporting PDFs)

TOPICS
Edit and convert PDFs

Views

538

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

correct answers 1 Correct answer

Community Expert , Apr 02, 2017 Apr 02, 2017

You need to select (with the mouse or the keyboard) the entire code before

executing it.

On Sun, Apr 2, 2017 at 12:18 PM, Just Shoot Me <forums_noreply@adobe.com>

Votes

Translate

Translate
Community Expert ,
Apr 02, 2017 Apr 02, 2017

Copy link to clipboard

Copied

You need to select (with the mouse or the keyboard) the entire code before

executing it.

On Sun, Apr 2, 2017 at 12:18 PM, Just Shoot Me <forums_noreply@adobe.com>

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
New Here ,
Apr 02, 2017 Apr 02, 2017

Copy link to clipboard

Copied

Sometimes when I select the entire code and press enter it executes and some time with the same code, the code just disappears ?

Any idea why this is happening ?    

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 ,
Apr 02, 2017 Apr 02, 2017

Copy link to clipboard

Copied

Not really, no... What code are you executing? What key are you pressing?

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 ,
Apr 02, 2017 Apr 02, 2017

Copy link to clipboard

Copied

... and, are you using a Mac or a Windows system?

This tutorial explains which keys to press in order to execute code in the console window: https://acrobatusers.com/tutorials/javascript_console

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
New Here ,
Apr 02, 2017 Apr 02, 2017

Copy link to clipboard

Copied

Ok. Yes. I mananged that some how. But some how this code does not work. Any idea why ?

function ZBookmark(bkm, nLevel)

{

for (var i = 0; i < nLevel; i++);

bkm.zoom = 1;

if (bkm.children != null)

for (var i = 0; i < bkm.children.length; i++)

ZBookmark(bkm.children, nLevel + 1);

}

console.clear(); console.show();

console.println("Setting Zoom Level");

ZBookmar(this.bookmarkRoot, 0);

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 ,
Apr 02, 2017 Apr 02, 2017

Copy link to clipboard

Copied

What makes you think that Bookmark objects have a "zoom" property?

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 ,
Apr 02, 2017 Apr 02, 2017

Copy link to clipboard

Copied

The following line makes no sense:

for (var i = 0; i < nLevel; i++);

Bookmarks doesn't have a property with the name "zoom"

bkm.zoom = 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
LEGEND ,
Apr 02, 2017 Apr 02, 2017

Copy link to clipboard

Copied

Not all bookmarks are link with go to a page view with a specific zoom.

Bookmarks can could be a link to a web page, run some custom JavaScript, open a destination, etc.

One cannot access the action associated with a specific bookmark in JavaScript so it might not be possible to add the zoom setting to a specific bookmark.

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 ,
Apr 02, 2017 Apr 02, 2017

Copy link to clipboard

Copied

LATEST

If what you're trying to do is change the Zoom Level associated with your bookmark then you should know it's not possible to do it with a script. It requires using a stand-alone tool (like this one I've developed: Custom-made Adobe Scripts: Batch Edit Zoom Level in Bookmarks) or possibly a plugin.

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