Hide button in standard DocInfoBar / Get notified when doc info bar is displayed  SOLVED

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

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

Hide button in standard DocInfoBar / Get notified when doc info bar is displayed

Post by zarkogajic »

Hi Support,

When opening documents in read-only mode (for the pure viewing functionality, forced by PermF_All), if a document is a PDF/A, the DocInfoBar will display:

image.png

I need to hide/remove the "Enable Editing" button.

I should be able to do so via IPXV_DocInfoBar::RemoveButton, but I do not know the nSpanID parameter for the call.

So, what are the spanID values for default info bar panes ?

Finally, how do I get notified when an info bar is to be displayed - so to remove the button at that moment (if needed)?

p.s.
Btw, I think this button should be hidden/removed by default if PermF_All is used when opening a document.


-žarko
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Hide button in standard DocInfoBar / Get notified when doc info bar is displayed

Post by zarkogajic »

Hi support,

Seems like the IDs of spans can be get from this list

docInfoBarSpan.ProFeaturesUsed
docInfoBarSpan.ViewSignVer
docInfoBarSpan.PDFA
docInfoBarSpan.DigiSig
docInfoBarSpan.Form
docInfoBarSpan.ApplyRedact
docInfoBarSpan.ApplySign
docInfoBarSpan.BrokenFlags
docInfoBarSpan.FlashAvail
docInfoBarSpan.UR3

I think the list is not complete - as the are more default bars, so please update the list here...

I've tried:

Code: Select all

  
  Document : IPXV_Document;
  id : integer;
...  
  id := Inst.Str2ID('docInfoBarSpan.PDFA', false);
  Document.InfoBar.RemoveAllButtons(id);
But the button is still displayed.

UPDATE: I've been calling the above code to early (tried in e.document.viewingStarted and e.pagesView.ready) - so when is it "late enough" to call this?

Update 2: Seems like e.document.activated is the correct moment, please confirm?

How do I get the button id on a particular span?

If possible: how to get notified when an info bar is to be displayed - as probably this is when I need to remove the button?

Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Hide button in standard DocInfoBar / Get notified when doc info bar is displayed

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

The e_documentView_ready event is an OK part. The Update of the InfoBar that shows or hides it comes before it.
And here's how you can hide that command button:

Code: Select all

if (e.nEventID == nIDS[(int)IDS.e_documentView_ready])
{
	uiInst.CmdManager.Cmds.Find("cmd.document.discardPDFA").Hidden = true;
}
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Hide button in standard DocInfoBar / Get notified when doc info bar is displayed

Post by zarkogajic »

Hi Alex,

That will make the command hidden globally (everywhere) - that's not what I can use.

I need to remove that button for a particular document.

I should be using the RemoveButton method of the InfoBar - but I do not know the ID of it.

Also, in the e_documentView_ready the HasSpan (for 'docInfoBarSpan.PDFA') will return false for a PDFA document - so I guess the InfoBar gets displayed at a later stage?

Also, what is the ID of the "Save As" button that appears on the docInfoBarSpan.BrokenFlags bar ?

p.s.
Or, those are added as commands to the InfoBar and I need to custom handle them - but how to hide a command item (if one exists here) in the OnGetItemState when there's no "hidden" state ...


zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Hide button in standard DocInfoBar / Get notified when doc info bar is displayed

Post by zarkogajic »

Support,

Ok, I've done a few more tests and here's my final take on this ( until some answer from you with a possible better approach :) )

For a PDFA document ('docInfoBarSpan.PDFA' span):

The Document.InfoBar.HasSpan returns true in e.document.activated.

I've also tried in e.document.viewingStarted, e.documentView.ready and e.pagesView.ready - in all those the HasSpan returns false.

I'm then using the ActiveView of a document to find a command bar named "cmdbar.docInfo" in the CmdPaneTop of ActiveView.

Once found, I'm using FindFirstItemByCmdID to find the command item (in this case "cmd.document.discardPDFA").

Then I can do Show (false) - to hide it. This does it.

BUT, I do not like where this all happens - as e.document.activated will be called everytime I have multiple documents open and activate each document's tab.

So, the final question: when to catch the first appearance of the InfoBar?

-žarko
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Hide button in standard DocInfoBar / Get notified when doc info bar is displayed

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

Here's an OK place for your case (the Button exists there already) and the code piece to do that:

Code: Select all

if (e.nEventID == nIDS[(int)IDS.e_document_activated])
{
	IPXV_Document pv = (PDFXEdit.IPXV_Document)e.pFrom;
	int nSpanID = pdfCtl.Inst.Str2ID("docInfoBarSpan.PDFA", false);
	int nButtonID = pdfCtl.Inst.Str2ID("cmd.document.discardPDFA", false);
	pv.InfoBar.RemoveButton(nSpanID, nButtonID);
}
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Hide button in standard DocInfoBar / Get notified when doc info bar is displayed

Post by zarkogajic »

Hi Alex,

Thanks.

Note my previous post.

Is "e.document.activated" really the correct (read "best") place (due to it being fired every-time the document gets active)?

Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Hide button in standard DocInfoBar / Get notified when doc info bar is displayed

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

Well I think so - the thing is that the event that I proposed earlier does happen when the button was already added. Basically the event e.document.activated happens when everything is ready for modification. Even if you call this method again for the removed button - nothing will happen.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Hide button in standard DocInfoBar / Get notified when doc info bar is displayed

Post by zarkogajic »

Hi Alex,

ok. Case closed.

Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Hide button in standard DocInfoBar / Get notified when doc info bar is displayed

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Hide button in standard DocInfoBar / Get notified when doc info bar is displayed

Post by zarkogajic »

Hi support,

I forgot about this one: can you please update this list:

docInfoBarSpan.ProFeaturesUsed
docInfoBarSpan.ViewSignVer
docInfoBarSpan.PDFA
docInfoBarSpan.DigiSig
docInfoBarSpan.Form
docInfoBarSpan.ApplyRedact
docInfoBarSpan.ApplySign
docInfoBarSpan.BrokenFlags
docInfoBarSpan.FlashAvail
docInfoBarSpan.UR3

and also please let me know which of the available spans include something like "save as" (or alike) option. Even better: please specify by-default added commands (or button) IDs for each.

Example: I was just hit with "...extended features in Adobe Reader..." - and it is not in the list - and I need to hide the "save as" button on it.

p.s.
If in the future new default spans are added - where can I get the IDs?

Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Hide button in standard DocInfoBar / Get notified when doc info bar is displayed

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

You can run though all of the IDs and search for the docInfoBarSpan string in the ID string - that's the fastest way.
Then by having all of the SpanID, you can call the RemoveAllButtons(spanID) method - that will clear all of the possible buttons.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Hide button in standard DocInfoBar / Get notified when doc info bar is displayed

Post by zarkogajic »

Hi Alex,

Thanks, but that is not what I need / what I asked.

I do not want to remove all buttons.

Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Hide button in standard DocInfoBar / Get notified when doc info bar is displayed

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

The id_docInfoBarSpan_ViewSignVer, id_docInfoBarSpan_BrokenFlags, id_docInfoBarSpan_UR3 has a save as command.
And the id_docInfoBarSpan_FlashAvail has the "Install Flash" command.


Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Hide button in standard DocInfoBar / Get notified when doc info bar is displayed

Post by zarkogajic »

Thanks Alex.

Still, can you please update this list:

I forgot about this one: can you please update this list:

docInfoBarSpan.ProFeaturesUsed
docInfoBarSpan.ViewSignVer
docInfoBarSpan.PDFA
docInfoBarSpan.DigiSig
docInfoBarSpan.Form
docInfoBarSpan.ApplyRedact
docInfoBarSpan.ApplySign
docInfoBarSpan.BrokenFlags
docInfoBarSpan.FlashAvail
docInfoBarSpan.UR3

as at least "...extended features in Adobe Reader..." is missing...

Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Hide button in standard DocInfoBar / Get notified when doc info bar is displayed

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

I think I've mentioned all of them that have such buttons.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Hide button in standard DocInfoBar / Get notified when doc info bar is displayed

Post by zarkogajic »

Alex,

Yes, thanks for that part.

The remaining question is: what are the string IDs of the rest of standard docinfobars? There are more than in "my" list.

I've specifically asked about the one displaying "...extended features in Adobe Reader...", this one

image.png
There are 12 possible bars in (335 version) and "my" list only has 10.


Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Hide button in standard DocInfoBar / Get notified when doc info bar is displayed

Post by Sasha - Tracker Dev Team »

Sasha - Tracker Dev Team wrote: Tue Apr 14, 2020 11:33 am You can run though all of the IDs and search for the docInfoBarSpan string in the ID string - that's the fastest way.
Then by having all of the SpanID, you can call the RemoveAllButtons(spanID) method - that will clear all of the possible buttons.
Have you done this part?

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Hide button in standard DocInfoBar / Get notified when doc info bar is displayed

Post by zarkogajic »

Hi Alex,

I do not know how to run through all the IDs.

Should I iterate Inst.ID2Str from 0 to what number?

Even if I do so and find all the InfoBar ID's - still the question is what standard commands are on a particular info bar.

As, again, I do not want to remove all buttons from an info bar.

Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Hide button in standard DocInfoBar / Get notified when doc info bar is displayed  SOLVED

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

docInfoBarSpan.UR3 - that's the one that holds that Acrobat Reader Protection.
As for the IDs - any large number will suffice - for example 100000.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Hide button in standard DocInfoBar / Get notified when doc info bar is displayed

Post by zarkogajic »

Hi Alex,

Thanks. that'll do it.


Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Hide button in standard DocInfoBar / Get notified when doc info bar is displayed

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply