Skip to main content
Participant
February 26, 2018
Question

Identify if bookmark is an even page

  • February 26, 2018
  • 2 replies
  • 343 views

Forum,

I'm looking for assistant building a script to determine if a bookmark is an even page.

If true, insert a blank letter before it.

If False, do nothing.

Thank you for any leads, I'm using Acrobat Pro 11 on windows 7.

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
February 26, 2018

There are various issues with this.

1) Not all bookmarks necessarily point to a page.

2) Even if you assume that they do, once you insert a page into the file, all the pages after it change their page number and the pages that were odd will now become event, and vice versa.

3) To solve #2 you can process the bookmarks tree backwards, but there's also no guarantee that the order of the bookmarks corresponds to the order of the pages they point to (if they point to a page at all, see #1).

In short, this is a complex and tricky task.

Participant
February 26, 2018

Responses in bold:

1) Not all bookmarks necessarily point to a page.

My documents have only parent bookmarks, and every bookmark links to a page.

2) Even if you assume that they do, once you insert a page into the file, all the pages after it change their page number and the pages that were odd will now become event, and vice versa.

My current workflow is to click on a bookmark from the start of the document, insert a blank page if it is an even page as necessary and move towards the end.

3) To solve #2 you can process the bookmarks tree backwards, but there's also no guarantee that the order of the bookmarks corresponds to the order of the pages they point to (if they point to a page at all, see #1).

In short, this is a complex and tricky task.

I agree.

try67
Community Expert
Community Expert
February 26, 2018

OK. You would need to create a look that iterates over the bookmarks tree and call the execute method on each item in it.

Then examine the pageNum property of the Document object and if it's an odd number (remember that page numbers are zero-based) then use the newPage command to add a new page to the file.

Inspiring
February 26, 2018

When you say "insert a blank letter before it", does "it" refer to the bookmark name, or something else?

Participant
February 26, 2018

It refers to insert a blank letter page before the bookmark.

The end result is that every bookmark is an odd page.