Combine text in Bookmarks from Page text SOLVED
Moderators: Daniel - PDF-XChange, PDF-XChange Support, Vasyl - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange
-
- User
- Posts: 567
- Joined: Thu Jun 19, 2014 7:30 pm
Combine text in Bookmarks from Page text
Is it possible to combine page text to generate a single bookmark for a page? What I'm looking for is some way to create bookmarks similar to this:
The page is set up with the title and sheet number separate:
If I use the generate bookmarks from page text and try to add both font styles thus:
It generates two separate bookmarks:
Is there a built-in way to do what I want?You do not have the required permissions to view the files attached to this post.
-
- Site Admin
- Posts: 11000
- Joined: Wed Jan 03, 2018 6:52 pm
Re: Combine text in Bookmarks from Page text
Hello, Mathew
At this time, I am afraid that there is no way to do this with bookmarks that we offer as a feature. There may be some workaround using advanced JS to modify the bookmarks after making them as per your last screenshot, but I cannot say I have ever seen a successful implementation.
With that said, this has seen a growing handful of requests to day, and while I cannot promise anything at the moment, the Dev team is aware that there are some people wish to accomplish this, so it may be something we look at in the future.
Kind regards,
At this time, I am afraid that there is no way to do this with bookmarks that we offer as a feature. There may be some workaround using advanced JS to modify the bookmarks after making them as per your last screenshot, but I cannot say I have ever seen a successful implementation.
With that said, this has seen a growing handful of requests to day, and while I cannot promise anything at the moment, the Dev team is aware that there are some people wish to accomplish this, so it may be something we look at in the future.
Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
PDF-XChange Co. LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
-
- User
- Posts: 567
- Joined: Thu Jun 19, 2014 7:30 pm
Re: Combine text in Bookmarks from Page text
OK, thanks - yes I can make a script to do that. However, I'm getting some weird (possible bug?) results when I run generate bookmarks on page text. Based on the following, I'd expect the hierarchy of bookmarks to be on the same page:
But I get the following - its a bit scrambled. For S0.1 the title is listed before it under "<untitled>" bookmark. For S0.3 it lists two items, but the text "BUILDING 'M' AND 'O' LEVEL 3 UNDERPINNING PLANS" is actually on, and links to the next sheet (S2.2). Same for all the bookmarks from there down.
BTW - here's a script to combine the bookmark names - it will only combine the names if the child bookmark links to the same page.
Code: Select all
// combine bookmark names
{
// this is the character that goes between the names
DELIM = " ";
function getPage(bkm) {
// does bookmark action and returns the page
bkm.execute();
return bkm.doc.pageNum;
}
function getNames(bkm, delim=" "){
// gets names of bookmarks to same page, then deletes the child bookmarks
let bName = bkm.name;
let bPg = getPage(bkm);
let bc = bkm.children;
if ( bc ) {
// step through children
for (let i = 0; i < bc.length; i++) {
// if child bookmark is same page, get its name
if (bPg == getPage(bc[i])) {
bName += delim + getNames( bc[i], delim );
// remove this bookmark
bc[i].remove();
}
}
}
return bName
}
// save the viewstate
let vState = this.viewState;
// step through bookmarks
let bkBase = this.bookmarkRoot.children;
for (let b of bkBase) {
b.name = getNames(b,DELIM);
}
// restore viewstate
this.viewState = vState;
}
You do not have the required permissions to view the files attached to this post.
-
- Site Admin
- Posts: 11000
- Joined: Wed Jan 03, 2018 6:52 pm
Re: Combine text in Bookmarks from Page text
Hello, Mathew
Could I possibly ask for a copy of the document, as well as an export of the "bookmarks from page text" you are using (you should be able to "manage > export" the "preset" in the bottom left area of the dialog), you may need to save your settings as a preset first.
Kind regards,
Could I possibly ask for a copy of the document, as well as an export of the "bookmarks from page text" you are using (you should be able to "manage > export" the "preset" in the bottom left area of the dialog), you may need to save your settings as a preset first.
Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
PDF-XChange Co. LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
-
- User
- Posts: 567
- Joined: Thu Jun 19, 2014 7:30 pm
Re: Combine text in Bookmarks from Page text
Yes, here's an example.
You do not have the required permissions to view the files attached to this post.
-
- User
- Posts: 567
- Joined: Thu Jun 19, 2014 7:30 pm
Re: Combine text in Bookmarks from Page text
If you add a third level to it, it becomes clearer. Looks like it considers the sequence of the text in the document, rather than the page number, in placing the bookmarks in the bookmark tree.
You do not have the required permissions to view the files attached to this post.
-
- Site Admin
- Posts: 11000
- Joined: Wed Jan 03, 2018 6:52 pm
Re: Combine text in Bookmarks from Page text SOLVED
Hello, Mathew
Good eye, I did pass this along to the dev team and they clarified that that is intended. Bookmarks are added in the order they appear on the page, if a child is above the parent on that page, it will eb associated to the parent of the page prior. This is unlikely to change, but the dev team is looking at possible options to allow some "after the fact" handling for your particular use case here.
I cannot make any promises for it to happen, but perhaps we will get lucky.
Kind regards,
Good eye, I did pass this along to the dev team and they clarified that that is intended. Bookmarks are added in the order they appear on the page, if a child is above the parent on that page, it will eb associated to the parent of the page prior. This is unlikely to change, but the dev team is looking at possible options to allow some "after the fact" handling for your particular use case here.
I cannot make any promises for it to happen, but perhaps we will get lucky.
Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
PDF-XChange Co. LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
-
- User
- Posts: 567
- Joined: Thu Jun 19, 2014 7:30 pm
Re: Combine text in Bookmarks from Page text
Thank you for looking into this Daniel.
It's not difficult to post-process this with javascript, so not really necessary within PDF XChange unless it's an option within this dialog.
OK, so bookmarks are added in the order they appear in the document, and it seems like page boundaries are ignored. It does seem counterintuitive if I think of a pdf document as a sequence of individual drawings. But it makes total sense, for example, if I'm finding headings in a book or report, and looking for text or sub-headings.TrackerSupp-Daniel wrote: ↑Thu Dec 14, 2023 10:32 pm Bookmarks are added in the order they appear on the page, if a child is above the parent on that page, it will eb associated to the parent of the page prior.
It's not difficult to post-process this with javascript, so not really necessary within PDF XChange unless it's an option within this dialog.
-
- Site Admin
- Posts: 7359
- Joined: Wed Mar 25, 2009 10:37 pm
Re: Combine text in Bookmarks from Page text
Hi, Mathew
OK - great that you can handle it as is. I guess we wait and see what the devs offer, if anything.
cheers
Kind regards,
Paul - Tracker Supp
OK - great that you can handle it as is. I guess we wait and see what the devs offer, if anything.
cheers
Kind regards,
Paul - Tracker Supp
Best regards
Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com
Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com
-
- User
- Posts: 567
- Joined: Thu Jun 19, 2014 7:30 pm
Re: Combine text in Bookmarks from Page text
Here's my script I made to handle this. It adds two menu items under "Tools" in the Classic UI. The menu item "Combine Bookmark Names" opens a dialog:
The menu item "Arrange Bookmarks by Sheet" just does the arranging (the first checkbox in the above dialog).
My process: Use the "Generate bookmarks from page text" tool, with the first text search for the sheet number, and a nested search for the sheet name. Then run this script to sort and combine the bookmark names.
While doing this I realized a better approach for drawing sets is to get bookmark names from selected areas on the sheets, rather than by trying to use patterns and text sizes to determine which text to grab. Bluebeam has a built-in script for doing this. A JavaScript tool for PDF XChange is posted here: viewtopic.php?t=42477
The menu item "Arrange Bookmarks by Sheet" just does the arranging (the first checkbox in the above dialog).
My process: Use the "Generate bookmarks from page text" tool, with the first text search for the sheet number, and a nested search for the sheet name. Then run this script to sort and combine the bookmark names.
While doing this I realized a better approach for drawing sets is to get bookmark names from selected areas on the sheets, rather than by trying to use patterns and text sizes to determine which text to grab. Bluebeam has a built-in script for doing this. A JavaScript tool for PDF XChange is posted here: viewtopic.php?t=42477
You do not have the required permissions to view the files attached to this post.
Last edited by Mathew on Fri May 24, 2024 10:03 pm, edited 2 times in total.
-
- Site Admin
- Posts: 11000
- Joined: Wed Jan 03, 2018 6:52 pm
Re: Combine text in Bookmarks from Page text
Hello, Mathew
Thank you for this, it looks like it may be handy for some users!
Kind regards,
Thank you for this, it looks like it may be handy for some users!
Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
PDF-XChange Co. LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
-
- User
- Posts: 567
- Joined: Thu Jun 19, 2014 7:30 pm
Re: Combine text in Bookmarks from Page text
The script wasn't working to combine bookmarks when there's only one level of bookmarks. Here's an updated version that I think resolves it:
For bookmarks generated from the page text:
Combined to make a single bookmark for each page:
You do not have the required permissions to view the files attached to this post.
-
- Site Admin
- Posts: 2206
- Joined: Mon Jan 15, 2018 9:01 am
Re: Combine text in Bookmarks from Page text
Thank you for your effort.