Automate new bookmark from page region selection  SOLVED

PDF-XChange Editor SDK for Developers

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

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
zarkogajic
User
Posts: 1473
Joined: Thu Sep 05, 2019 12:35 pm

Automate new bookmark from page region selection

Post by zarkogajic »

Hi Support,

I'm trying to "automate" generation of new bookmark from page region selection.

I'll raise 3 questions here...

I'd like a new bookmark to be added upon selecting a region on a page - without the need to also execute "add new bookmark".

So, in images, I want to have the same result as the following - but last step from code:

Step 1:
image.png
Step 2:
image(1).png
Step 2 (another way - same result - using Bookmarks Pane):
image(2).png

Question 1: how to differentiate between tool.selPageRegions and tool.selPageRegions.cut - tool activated by "cmd.tool.selPageRegions.cut" ?

In Q2 ActiveTool is "selection.pageRect" even if command executed was cmd.tool.selPageRegions.cut or cmd.tool.selPageRegions.delete.

Question 2:

My code idea so far (pseudo):

Code: Select all

On e.docSelection.changed
doc = IPXV_Document(pFrom);
If doc.ActiveSel.ID = "selection.pageRect"
If doc.ActiveTool.ID = "tool.selPageRegions"
{
InstUI.CmdManager.ExecCmd('cmd.bookmarksView.new', doc.ActiveView.Obj);
doc.ActiveSel.Clear;
pEvent.Handled = true;
}
Without the ExecCmd line - selection is cleared and nothing happens as expected.

With ExecCmd - I have stack overflow as ExecCmd re-raises e.docSelection.changed (selection.bookmarks) and this code runs in circles.

Actual question: what other options do I have to create bookmark (from selection) and clear selection?

Question 3:

I have noticed the following: if the snapshot tool is activated and some snapshot taken (so there is snapshot-selection) - activating "Select Page Region" (from UI) would raise e.docSelection.changed AND ActiveSel.ID would be "selection.pageRect" AND ActiveTool.ID = "tool.selPageRegions" - BUT the selection would still be from the Snapshot tool - so selection from snapshot not cleared before event happens.



-žarko
You do not have the required permissions to view the files attached to this post.
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 11036
Joined: Wed Jan 03, 2018 6:52 pm

Re: Automate new bookmark from page region selection

Post by Daniel - PDF-XChange »

Hello, zarkogajic

Thank you for the inquiry, I have asked the Dev team to come take a look once they are able. Hopefully they can get back to us in a timely manner.

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
zarkogajic
User
Posts: 1473
Joined: Thu Sep 05, 2019 12:35 pm

Re: Automate new bookmark from page region selection  SOLVED

Post by zarkogajic »

Hi Support,

I'll close this topic as I have implemented what I needed using the FullDemo.CustomTool code ...

-žarko
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19868
Joined: Mon Jan 12, 2009 8:07 am

Re: Automate new bookmark from page region selection

Post by Stefan - PDF-XChange »

Hello zarkogajic,

Thanks! Glad to hear that you managed to get your desired outcome with the full demo custom tool code!

Kind regards,
Stefan