Locate Bookmark (page) and insert blank page if page number is even

Post Reply
Barnie
Newbie
Posts: 2
Joined: Sat Sep 30, 2023 11:22 am

Locate Bookmark (page) and insert blank page if page number is even

Post by Barnie »

Hi guys :-)

Recently I was happy to find the new bookmarks features, but as they are I think there are further helpful consecutive actions needed.

In this case I'd like to locate all bookmarked pages , check if they are even or odd ones and in case of even, I need to insert a blank page.
The intent is obvious: Making sure the new chapter (bookmark) will start on a right handed page / new page.

I tried to combine the bookmark action [select page by bookmark] AND [Select even pages] followed by [Add page] ...

That doesn't work overall like that - the first page selected works fine, afterwards it puts blank pages "at random" or not:-)
(but I must admit, I didn't use a lot operators and/or/not til now)
My guess: The odd/even positions are not available consecutively but only at one first instant, and thereafter the decision where to insert is kept although the insertion several pages before may alter the pages later on at runtime (?)
freddyp
Advanced member
Posts: 1129
Joined: Thu Feb 09, 2012 3:53 pm

Re: Locate Bookmark (page) and insert blank page if page number is even

Post by freddyp »

The order of the actions in your action list is incorrect. The operators AND/OR/NOT have to come AFTER the operands. The correct order is:
Select pages with bookmarks
Select even pages
AND
Add pages

Do your documents only have top-level bookmarks, or do they form a tree structure. If the latter, it will not work correctly.

Do you have Switch? Is it OK if the final result is correct, but the bookmarks are lost?
Barnie
Newbie
Posts: 2
Joined: Sat Sep 30, 2023 11:22 am

Re: Locate Bookmark (page) and insert blank page if page number is even

Post by Barnie »

Hi freddyp

and thanks for the quick response.
Actually I wasn't too precise in describing the routine's order....
The AND operator surely followed the two operands exactly as you stated here.

But yeah, there is a tree-structure below level1 bookmarks.
As I merged all the PDFs I used a known prefix to all the resulting top-level bookmarks in order to identify those. (Select pages with bookmarks optionally matching Name: "54321" )
It doesn't actually match, as it's only a part of the bookmark name. I guess that is the error and the bookmark tree below as well.

So, thank you ! Good to know what I don't know :D
I'll be testing with proper data once more (soon)

PS: No , we don't use Switch by now
User avatar
Terkelsen
Advanced member
Posts: 336
Joined: Thu Sep 08, 2011 5:08 pm
Contact:

Re: Locate Bookmark (page) and insert blank page if page number is even

Post by Terkelsen »

You have an option to use regular expressions to define the names. That might help to match all the names.
freddyp
Advanced member
Posts: 1129
Joined: Thu Feb 09, 2012 3:53 pm

Re: Locate Bookmark (page) and insert blank page if page number is even

Post by freddyp »

(Select pages with bookmarks optionally matching Name: "54321" )
If all your top-level bookmarks start with 54321 and the lower-level do not, then you indeed have a way of filtering only the top-level ones. However, it is not with 54321 as a regular expression that it will work, but with 54321.+ meaning 54321 followed by any character one or multiple times. The regular expression has to match the whole string. As the 54321 is not likely to be fixed, the regex could be something like \d{5}\s.+ which means 5 digits followed by a space followed by one more characters (as the people who attended the January 2025 workshop held by Loïc yesterday will know :D).
Post Reply