386 Feature Request: Apply Bookmark to Page Label

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

User avatar
PHK
User
Posts: 1627
Joined: Tue Nov 24, 2020 4:02 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by PHK »

Thanks for sorting this out, Mathew. I was quickly developing the impression the solution was above my pay grade.

Glad you got there in the end, ANR!
All best,

FringePhil
ANR_Designs_NC
User
Posts: 10
Joined: Wed Sep 24, 2025 6:41 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by ANR_Designs_NC »

PHK wrote: Thu Sep 25, 2025 7:23 pm Thanks for sorting this out, Mathew. I was quickly developing the impression the solution was above my pay grade.

Glad you got there in the end, ANR!
Thanks. This is extremely beneficial when combining large sets of drawing packages.
User avatar
Dimitar - PDF-XChange
Site Admin
Posts: 2732
Joined: Mon Jan 15, 2018 9:01 am

386 Feature Request: Apply Bookmark to Page Label

Post by Dimitar - PDF-XChange »

:)
User avatar
Mathew
User
Posts: 888
Joined: Thu Jun 19, 2014 7:30 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by Mathew »

I've updated the tool to add optional regular expression to check against the bookmarks before assigning page labels, and option to add page numbering to the label. This change allows me to number pages based on just part of the bookmark.

If regex is left blank, and page numbering is <None> it works the same as before.
image.png
applyBkNameToLabel v2.0.zip
If you’re updating in v11 or later, the location of the JavaScript folder has moved! viewtopic.php?t=49522

tl;dr
I frequently combine multiple individual pdf files to make one file, and use the New Document > Combine Files into a Single PDF command to do that (it adds root bookmarks for each, and includes their bookmarks, which is great). The problem I was having was that I also want to set page numbering, and that command (as of PXCE v.11.0.1) loses those page numbers. I'd not thought of using my tool until FringePhil explained how in this post: viewtopic.php?p=204264#p204264

Thus I can take bookmarks like this:
image(1).png
and if I put a regular expression to just match the number at the beginning (ie with the settings shown on the image of the tool dialog above), it will number pages using just the matching part. ie, for 06.1 the pages would be numbered
06.1.1, 06.1.2, 06.1.3, ...
and the next section 07.0 would be
07.0.1, 07.0.2, ....
etc

Changes in v2.0
  • add regex to set label;
  • option to add number;
  • add progress dialog when looking for current page bookmark;
  • new dialog for label from bookmarks
You do not have the required permissions to view the files attached to this post.
Last edited by Mathew on Tue Jul 14, 2026 3:01 pm, edited 1 time in total.
User avatar
PHK
User
Posts: 1627
Joined: Tue Nov 24, 2020 4:02 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by PHK »

Thank you, Mathew, for this enhancement. Beyond you and me, I am sure that many PDFXCE users will benefit and appreciate what you have done although it may have ruined your weekend. I had the feeling that I could hear the wheels churning from your region as you grappled with the challenge.

It may be obvious but that won't prevent me from stating the following. With this tool, users can now 'incrementalize' (if there is such a word) files and easily produce new updated Page Labels, or 'Titles'. By 'incrementalize', I mean add new pages to pre-existing file perhaps as new data pages are inserted. In other words, this addresses your, Mathew, FR regarding saving page labels viewtopic.php?t=49803.

Again, a huge Thank You!
All best,

FringePhil
User avatar
PHK
User
Posts: 1627
Joined: Tue Nov 24, 2020 4:02 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by PHK »

Sorry, but I'm feeling a bit brain-dead at the moment...I have forgotten how to link a tool icon to a java script, like in this case. I have replaced the prior version of the applyBkNametoLabel script in the JavaScript folder but I am stuck because I cannot remember what to do next. So, when I click on the corresponding tool icon, it runs v1.1, not v2.0. What am I doing/not doing wrong?
All best,

FringePhil
User avatar
Mathew
User
Posts: 888
Joined: Thu Jun 19, 2014 7:30 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by Mathew »

PHK wrote: Tue Jul 14, 2026 10:21 am Sorry, but I'm feeling a bit brain-dead at the moment...I have forgotten how to link a tool icon to a java script, like in this case. I have replaced the prior version of the applyBkNametoLabel script in the JavaScript folder but I am stuck because I cannot remember what to do next. So, when I click on the corresponding tool icon, it runs v1.1, not v2.0. What am I doing/not doing wrong?
Not you at all: I suspect it’s the same head scratcher I ran into: v11 of PXCE moved where the JavaScript folder is. They left the old one and copied everything to the new one. Very confusing.

For PDFX-Change before version 11:
%APPDATA%\Tracker Software\PDFXEditor\3.0

Version 11 onwards, the folder moved:
%APPDATA%\PDF-XChange\PDF Editor
User avatar
Mathew
User
Posts: 888
Joined: Thu Jun 19, 2014 7:30 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by Mathew »

PHK wrote: Tue Jul 14, 2026 8:49 am Thank you, Mathew, for this enhancement. Beyond you and me, I am sure that many PDFXCE users will benefit and appreciate what you have done although it may have ruined your weekend. I had the feeling that I could hear the wheels churning from your region as you grappled with the challenge.

In other words, this addresses your, Mathew, FR regarding saving page labels viewtopic.php?t=49803.
😂 I enjoy this tinkering.

You’re right: I think this approach that you suggested is actually much better than what I’d envisioned with my feature request because it completely automated the page numbers. I think it cut down a rather painful meticulous process into two easy steps, given that I name the files already with the numbering: merge the documents then run this tool. I add a step after to add headers and footers but I can use the page labels for the page numbers in those so that is also easy (I used to do it individually for each section before combining).
User avatar
Sean - PDF-XChange
Site Admin
Posts: 1152
Joined: Wed Sep 14, 2016 5:42 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by Sean - PDF-XChange »

:)
Sean Godley
Technical Writer
PDF-XChange Co LTD
Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623
User avatar
PHK
User
Posts: 1627
Joined: Tue Nov 24, 2020 4:02 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by PHK »

Mathew wrote: Tue Jul 14, 2026 3:07 pm ... I add a step after to add headers and footers but I can use the page labels for the page numbers in those so that is also easy (I used to do it individually for each section before combining).
Actually, I have been doing something similar although in a completely different field: legal documents. Legal filings and court documents traditionally are formatted in an hierarchical outline framework over as many pages as it takes, frequently into the hundreds of pages. I de-paginate the content and show the content in the source three-dimensional outline. I gather all footnotes into one vertical page (rarely breaking it down into multiple columns to fit them into restricted space as below) which I stamp onto the document sheet as part of the finalization process. I adopt the outline titles as Bookmarks which become very important navigational devices.

As an example, this was about fifty pages.

image.png

I then build a file, document by document, using the Combine Files tool. Each parent Bookmark is [yy-mm-dd] and a short text title. And the child Bookmarks are carried into the merged sheet from the original one-page[sheet] file. Using v1.1, the Page titles in the Thumbnails panel were a bit long, mostly not visible. V2.0 solves this for me. So now, page titles can be only the date without the text clutter.

image(1).png

In this way I can see all the important documents relating to a single case in a single file and I can navigate from document to document and page to page using Bookmarks and I create new sheets and combine them into the matter file using the Combine files tool as they come along. I can also create Comments that relate to single issues but range over many documents/pages. In this fashion, not only am I avoiding having to jump from page to page but also avoiding going from file to file, making everything vastly more comprehendable more quickly.
You do not have the required permissions to view the files attached to this post.
Last edited by PHK on Tue Jul 14, 2026 5:07 pm, edited 3 times in total.
All best,

FringePhil
User avatar
PHK
User
Posts: 1627
Joined: Tue Nov 24, 2020 4:02 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by PHK »

Mathew wrote: Tue Jul 14, 2026 2:44 pm
Not you at all: I suspect it’s the same head scratcher I ran into: v11 of PXCE moved where the JavaScript folder is. They left the old one and copied everything to the new one. Very confusing.

For PDFX-Change before version 11:
%APPDATA%\Tracker Software\PDFXEditor\3.0

Version 11 onwards, the folder moved:
%APPDATA%\PDF-XChange\PDF Editor
Ah, yes, I forgot about that "enhancement" and this is the first time it has come up for me. :oops:
All best,

FringePhil
User avatar
PHK
User
Posts: 1627
Joined: Tue Nov 24, 2020 4:02 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by PHK »

OK, Mathew, I've got V2.0 working but I am not up on how to set the parameters.

Simply put, your example above doesn't (and shouldn't, I expect) work for the formats I am using.

Which is yy-mm-dd, like today is 26-07-14 (Happy Bastille Day!)

What parameter set should I employ?
All best,

FringePhil
User avatar
Mathew
User
Posts: 888
Joined: Thu Jun 19, 2014 7:30 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by Mathew »

PHK wrote: Tue Jul 14, 2026 4:46 pm OK, Mathew, I've got V2.0 working but I am not up on how to set the parameters.

Simply put, your example above doesn't (and shouldn't, I expect) work for the formats I am using.

Which is yy-mm-dd, like today is 26-07-14 (Happy Bastille Day!)

What parameter set should I employ?
Regular expressions take a bit to learn. For your date format above (if that's all you wanted to match - allowing for one or two digits at month and day):

Code: Select all

\d{2}-\d{1,2}-\d{1,2}
Happy Bastille Day :)
User avatar
Mathew
User
Posts: 888
Joined: Thu Jun 19, 2014 7:30 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by Mathew »

if it's always 2 digits at each, simpler:

Code: Select all

\d{2}-\d{2}-\d{2}
or easier to understand (\d means a numerical digit 0-9)

Code: Select all

\d\d-\d\d-\d\d
If working with drawings and you want to isolate just the sheet number (typically in the format S5.10 or FP9-4A etc)

Code: Select all

^[A-Z]+[A-Z\d.-]+
If sheet numbers may have a space after the initial letters (i.e. A 7.4)

Code: Select all

^[A-Z]+ ?[A-Z\d.-]+
The regular expressions are case sensitive, so if there may be lowercase letters, it will need to be included in the regex (ie L8.3a), for example:

Code: Select all

^[A-Z]+[A-Za-z\d.-]+
Last edited by Mathew on Fri Jul 17, 2026 4:30 pm, edited 3 times in total.
User avatar
PHK
User
Posts: 1627
Joined: Tue Nov 24, 2020 4:02 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by PHK »

Mathew wrote: Tue Jul 14, 2026 7:19 pm if it's always 2 digits at each, simpler:

Code: Select all

\d{2}-\d{2}-\d{2}
or easier to understand (\d means a numerical digit 0-9)

Code: Select all

\d\d-\d\d-\d\d
Ah, thank you, Mathew, that works beautifully!
All best,

FringePhil
User avatar
Sean - PDF-XChange
Site Admin
Posts: 1152
Joined: Wed Sep 14, 2016 5:42 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by Sean - PDF-XChange »

:)
Sean Godley
Technical Writer
PDF-XChange Co LTD
Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623
User avatar
Mathew
User
Posts: 888
Joined: Thu Jun 19, 2014 7:30 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by Mathew »

I noticed a bug when using apply bookmark for current page. Also added option for the start page number if using numbering.
applyBkNameToLabel v2.1.1.zip

Changes in v2.1
  • add option for start number;
  • fix bug when no bookmark matches current page with regex: filter bookmarks matching current page against regex and show warning if none;
  • use 'n' for roman zero https://en.wikipedia.org/wiki/Roman_numerals#Zero
Sean - PDF-XChange wrote: Wed Jul 15, 2026 3:32 pm :)
sorry to reopen Sean ;)
You do not have the required permissions to view the files attached to this post.
User avatar
Mathew
User
Posts: 888
Joined: Thu Jun 19, 2014 7:30 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by Mathew »

[edit] After I uploaded v2.1, I realized that pdf's won't let one use zero for a page number, so fixed it with v2.1.1... I think there was one download of v2.1 so, whoever you are, if page numbering lets you enter zero... it's wrong. Fixed in 2.1.1. :oops:

Change v2.1.1
  • Prevent script from trying to use zero as starting number.
Last edited by Mathew on Fri Jul 17, 2026 10:29 pm, edited 1 time in total.
User avatar
PHK
User
Posts: 1627
Joined: Tue Nov 24, 2020 4:02 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by PHK »

No problem, a simple fix for me.
All best,

FringePhil
User avatar
PHK
User
Posts: 1627
Joined: Tue Nov 24, 2020 4:02 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by PHK »

Hi, Mathew, I am having a few problems with V2.1.1.

  • On pre-existing files, some pages do not show the Bookmark as a label/title. All the Bookmarks seem similarly formatted so it is not immediately apparent why some work and some don't.
  • I cannot see how to suppress the suffix numbering process. However I set up the interact box, I get an unwanted numerical sequential suffix.
  • I don't know enough about regex to set it up so that I get exactly what I want. For instance, now I would like another digit string added to the label/title. So in addition to the \d\d-\d\d-\d\d for yy-mm-dd, I would like some thing that produces a page label 'yy-mm-dd nnn' from a typical Bookmark string that looks like this: '26-07-20 [022]' i.e., the page label '26-07-20 022'.
It might not be best to do this in the forum as it is pretty specific to my requirements, so I would be happy to send you one-on-one a link to a file that typifies my issues if you would be happy to play around with it. Please advise.
All best,

FringePhil
User avatar
Mathew
User
Posts: 888
Joined: Thu Jun 19, 2014 7:30 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by Mathew »

PHK wrote: Mon Jul 20, 2026 11:42 am Hi, Mathew, I am having a few problems with V2.1.1.

  • On pre-existing files, some pages do not show the Bookmark as a label/title. All the Bookmarks seem similarly formatted so it is not immediately apparent why some work and some don't.
  • I cannot see how to suppress the suffix numbering process. However I set up the interact box, I get an unwanted numerical sequential suffix.
  • I don't know enough about regex to set it up so that I get exactly what I want. For instance, now I would like another digit string added to the label/title. So in addition to the \d\d-\d\d-\d\d for yy-mm-dd, I would like some thing that produces a page label 'yy-mm-dd nnn' from a typical Bookmark string that looks like this: '26-07-20 [022]' i.e., the page label '26-07-20 022'.
It might not be best to do this in the forum as it is pretty specific to my requirements, so I would be happy to send you one-on-one a link to a file that typifies my issues if you would be happy to play around with it. Please advise.
Sorry, I've been away, so only just saw this. In response to your comments
  • I'll take a closer look at the code. Very likely I messed something up. Will post an update if I figure it out.
  • again, something I probably messed up. Will fix.
  • Regex are difficult to learn. The page label will match whatever the regex matches, so for '26-07-20 [022]' the regex would be

    Code: Select all

    \d\d-\d\d-\d\d \[\d+\]
    the + symbol means "1 or more repetitions" and the square brackets need to be escaped with a backslash. The script won't replace or change things, so if your bookmark has square brackets, I've not put a way for the script to know that you don't want them in the resulting page label
Not sure I want to post my email address on this forum directly, because I'm concerned about even more bots picking it up for spam. I don't know if there's a way to pm with this forum...
User avatar
PHK
User
Posts: 1627
Joined: Tue Nov 24, 2020 4:02 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by PHK »

No problem, Mathew. Certainly, do not post your email here or anywhere in view of the unfortunate risks.
All best,

FringePhil
User avatar
Mathew
User
Posts: 888
Joined: Thu Jun 19, 2014 7:30 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by Mathew »

PHK wrote: Mon Jul 20, 2026 11:42 am
  • I cannot see how to suppress the suffix numbering process. However I set up the interact box, I get an unwanted numerical sequential suffix.
I found some bugs, and fixed them in v2.2 below. Be sure to set Number type to <None> if you don't want the numerical suffix:
image.png
PHK wrote: Mon Jul 20, 2026 11:42 am
  • On pre-existing files, some pages do not show the Bookmark as a label/title. All the Bookmarks seem similarly formatted so it is not immediately apparent why some work and some don't.
I can't figure this one out. I suspect that the regular expression is not matching. In the v2.2 I've added output to the console if it does not match, so maybe try running and see if there's console output saying something like "page 1: Bookmark 'page a' did not match regex - skipped."

If this is still not working, could you post a screen capture of the bookmark names that don't work and the regex you are using? thanks!
applyBkNameToLabel v2.2.zip

Changes v2.2:
  • add console output for bookmarks that don't match regex;
  • fix saving number type preference;
  • add alert at end stating number of page labels changed;
  • VERBOSE_CONSOLE option (line 25) to output information on what was changed to the console
You do not have the required permissions to view the files attached to this post.
User avatar
PHK
User
Posts: 1627
Joined: Tue Nov 24, 2020 4:02 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by PHK »

@Mathew: I am still getting numerical suffices with 2.2.

image.png

I must note that the Style setting in the Page Numbering app window was set for "None" before running 2.2 and, as you can see, it shows the "1,2,3," style after.

This is my entry set up which I think is correctly configured.

image(1).png

Don't waste too much time on this; it is a minor inconvenience that I can live with and I appreciate everything you've already done, Mathew.
You do not have the required permissions to view the files attached to this post.
All best,

FringePhil
User avatar
Sean - PDF-XChange
Site Admin
Posts: 1152
Joined: Wed Sep 14, 2016 5:42 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by Sean - PDF-XChange »

Hi FringePhil,

Okay - let's wait to see what Mathew says here.

Kind regards,
Sean Godley
Technical Writer
PDF-XChange Co LTD
Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623
User avatar
Mathew
User
Posts: 888
Joined: Thu Jun 19, 2014 7:30 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by Mathew »

Hi FringePhil,
well, I have to admit I'm flummoxed.

Is this when the tool is applied to a document that already has page labels on the pages? I can't seem to duplicate your result for the numbering, but I did notice one thing:

Because javascript does not get detailed information about page labels, just the displayed text, my tool does have the limitation that if page labels are already applied to the following page, then it can't know for sure whether the page label on the following page is something you want to keep (ie if it is a new range label or a continuation of the current page range). The tool just checks if the page label for the following page is the same as the page number, and starts a new range there if it is. A possible workaround might be to use the Page Numbering built-in tool to "Reset ranges…" before running this tool (??)

Mathew.
User avatar
PHK
User
Posts: 1627
Joined: Tue Nov 24, 2020 4:02 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by PHK »

Thanks for getting back so quickly. However: bad news. I had already cleared the labels as you suggest.
All best,

FringePhil
User avatar
Mathew
User
Posts: 888
Joined: Thu Jun 19, 2014 7:30 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by Mathew »

See the attached pdf. Does it work with this one? Seems to work for me:
image.png
image(1).png
test bookmarks.pdf
Grasping at straws here: Is it possible that you copied the new version into the old Tracker Software\PDFXEditor\3.0\ folder so it didn't update???
You do not have the required permissions to view the files attached to this post.
User avatar
PHK
User
Posts: 1627
Joined: Tue Nov 24, 2020 4:02 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by PHK »

Mathew wrote: Tue Aug 04, 2026 7:48 pm See the attached pdf. Does it work with this one? Seems to work for me:
image.png
image(1).png

test bookmarks.pdf
Grasping at straws here: Is it possible that you copied the new version into the old Tracker Software\PDFXEditor\3.0 folder so it didn't update???
Your's looks good, mine doesn't.

Doesn't this look like the right place?

image.png
You do not have the required permissions to view the files attached to this post.
All best,

FringePhil
User avatar
Mathew
User
Posts: 888
Joined: Thu Jun 19, 2014 7:30 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by Mathew »

the modification date is 18/07/2026 so that's not the v2.2 version.
User avatar
PHK
User
Posts: 1627
Joined: Tue Nov 24, 2020 4:02 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by PHK »

I have now deep-dived into my PC and found three other appdata locations that had old JSs for this in them and deleted them all.

And I still get numeric suffices.
All best,

FringePhil
User avatar
Mathew
User
Posts: 888
Joined: Thu Jun 19, 2014 7:30 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by Mathew »

Three locations!! Well, maybe it would be good to try deleting the tool entirely and restarting PDF XChange to be sure you've found all the possible locations. Once that's done and you're sure there are no other copies hiding (for example in C:\Program Files\PDF-XChange\PDF Editor\JavaScripts\), install the script again.

As we've spent a lot of effort on this -- would be nice to get to the bottom of it. The javascript file itself (inside the zip) should have a modification date of August 3rd for v2.2:
image.png
It could be something else: If the above doesn't work, would you mind installing a test version that outputs more to the console, and letting me know what you see output to the console when you run the tool?
applyBkNameToLabel v2.2test.zip
You do not have the required permissions to view the files attached to this post.
User avatar
PHK
User
Posts: 1627
Joined: Tue Nov 24, 2020 4:02 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by PHK »

MYSTERY SOLVED!

Unsurprsingly, it was all down to Operator Error. In other words, I screwed it up. Obviously, I was confused over the various multiple folder locations where the tool might be located. Mathew's spotting of the incorrect version date in the correct AppData folder was the key.

So now I can confirm that the tool seems to be working beautifully.

And, thank you, Mathew for accompanying me down this rabbit hole and I sincerely apologize for wasting your time on this and all other readers of this thread.
All best,

FringePhil
User avatar
Mathew
User
Posts: 888
Joined: Thu Jun 19, 2014 7:30 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by Mathew »

:D
So satisfying to figure it out
User avatar
PHK
User
Posts: 1627
Joined: Tue Nov 24, 2020 4:02 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by PHK »

:oops:
All best,

FringePhil
User avatar
Sean - PDF-XChange
Site Admin
Posts: 1152
Joined: Wed Sep 14, 2016 5:42 pm

Re: 386 Feature Request: Apply Bookmark to Page Label

Post by Sean - PDF-XChange »

:)
Sean Godley
Technical Writer
PDF-XChange Co LTD
Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623