Request: IPogressCallback for various op.'s  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

Request: IPogressCallback for various op.'s

Post by zarkogajic »

Hi Support,

I know we (developers) *love* to receive feature requests from users :) So, here's one:

(btw, if what I'm asking for already exists - ignore - and let me know "how to").

Given that in V9 this (https://forum.pdf-xchange.com/viewtopic.php?f=66&t=35246) has been solved (a BIG thanks!), I can now use it - seems like no deadlocks any more.

So, here's what I would love to see added to SDK: something like IProgressCallback I could specify for various IOperation's. When the Do() method is executed on a lengthy operation - have some IProgressCallback's method be called with the progress value.

Here's why: I'm using "op.document.addHeaderAndFooter", executing the Do() with OpExecFlag_NoProgress - I cannot have it "hijack" DefaultProgressMon since I'm using it for multiple background tasks, each doing several op.something's (https://forum.pdf-xchange.com/viewtopic.php?f=66&t=35252), so DefaultProgressMon is completely under my control. Also, I cannot use CreateStdRangeProgressMon as it depends on the DefaultProgressMon.

Here's another why: say I want to do op.document.addHeaderAndFooter - but I want my progress UI element being used (so something that has nothing to do with your IProgressMon) - I would need a way to be notified about the progress and update my UI as I need it.

I know you would not need this in EU Editor - as you use DefaultProgressMon for any lengthy progress - but we, users of SDK, might want to use something else for progress indicator :)


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

Re: Request: IPogressCallback for various op.'s

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

Some of the operations do have an external IProgress object that can be specified in CAB. Though there aren't so many of these available. I will ask how this can be updated for all of them.

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

Re: Request: IPogressCallback for various op.'s

Post by zarkogajic »

Hi Alex,

Thanks! Can you name one that has it - just to see how this is implemented....


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

Re: Request: IPogressCallback for various op.'s

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

That was a time-consuming task, but now it's done. All of the operations that were using the get_ProgressMon method inside will have a Progress CAB item that can use the outside progress, passed to the operation.
This will be available in the 353 build.

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

Re: Request: IPogressCallback for various op.'s

Post by zarkogajic »

Hi Alex,

Can you please provide more info before 353 goes out.

How will that work - some new interface that should be implemented that will receive progress value?


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

Re: Request: IPogressCallback for various op.'s

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

If you have operation's Options dictionary, it will include the Progress dictionary that you can set with the IProgerssMon interface derived class.

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

Re: Request: IPogressCallback for various op.'s

Post by zarkogajic »

Hi Alex,

I see 352 is out.

How would that work for, example, op.document.addHeaderAndFooter?

IOperation op.Params.Root['Options']['Progress'].v = ?

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

Re: Request: IPogressCallback for various op.'s

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

Well it should be in the 353.
As an easiest example, you can obtain the ProgressMon from the IPXV_Inst and pass it in place of the ? in your sample.
Or you can create your class, derived from the IProgressMon interface, implement the needed methods and then create an instance of that class and pass it in place of the ? in your sample. In this case, you will be able to listen to all of the methods called by the operation and store/give that data from the custom progress class.
Also, you can implement your class as a listener by using the IPXV_Inst::get_ProgressMon and calling it's methods from your custom Progress class.

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

Re: Request: IPogressCallback for various op.'s

Post by zarkogajic »

HI Alex,

Ah sorry .. now I see you stated "353" - ok, waiting for it ...

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

Request: IPogressCallback for various op.'s  SOLVED

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Sascha Wächterowitz
User
Posts: 3
Joined: Tue Oct 12, 2021 8:17 am

Re: Request: IPogressCallback for various op.'s

Post by Sascha Wächterowitz »

Hi,

can someone confirm that this is in the current release and works with op.document.extractPages

I have downloaded version 9.1.356.0 of PDF Editor 9.1.356.0 but I can't get this to work the C# code

ICabNode progress = Op.Params.Root["Options"]["Progress"];
progress.v = progressMon;

I get the exception System.ArgumentException: Der Wert liegt außerhalb des erwarteten Bereichs.
at PDFXEdit.ICabNode.set_v(Object Val)
The exception text is german and can be translated to The value is outside the expected range.

Also I do not find a documentation for a Progress CAB in the actual documentation that it is implemented for the op.document.extractPages.

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

Re: Request: IPogressCallback for various op.'s

Post by zarkogajic »

Hi Sascha,
Sascha Wächterowitz wrote: Tue Oct 12, 2021 8:47 am ICabNode progress = Op.Params.Root["Options"]["Progress"];
progress.v = progressMon;
In the above, what is "progressMon" ?



-žarko
Sascha Wächterowitz
User
Posts: 3
Joined: Tue Oct 12, 2021 8:17 am

Re: Request: IPogressCallback for various op.'s

Post by Sascha Wächterowitz »

Hi zarkogajic ,

it is a small class that implements IProgressMon and IFlag that writes to our logger.
zarkogajic
User
Posts: 1370
Joined: Thu Sep 05, 2019 12:35 pm

Re: Request: IPogressCallback for various op.'s

Post by zarkogajic »

Hi Sascha,

It seems the "Progress" node is not implemented for "op.document.extractPages" options.

If you do Op.Params.Root["Options"].ItemExists("Progress", dt_IUnknown) you will receive false value.

Therefore custom IProgressMon is not applicable here :(

It is there, for example, for op.document.addHeaderAndFooter - and with that operation - you can set your own IProgressMon.

Note what Alex said:
All of the operations that were using the get_ProgressMon method inside will have a Progress CAB item that can use the outside progress, passed to the operation.
So, either op.document.extractPages was not using it (strange) or yes, there's something wrong here...

However, you can take a different approach (that's what I'm doing - I have DefaultProgressMon completely under my control):
... you can implement your class as a listener by using the IPXV_Inst::get_ProgressMon and calling it's methods from your custom Progress class..sour.
What this means is the following:

1. Create your class "MyProgressMonitor" implementing IProgressMonitor (you have that already)
2. Store the reference "DefaultProgress" monitor by getting it via "Inst.DefaultProgressMon" as a filed in your MyProgressMonitor
3. When needed, set your implementation for Inst.ProgressMon = MyProgressMonitor
4. Inside your MyProgressMonitor.SetPos implementation, for example, call "DefaultProgress.SetPos" (and then whatever you need to do when the Pos changes)
5. When no longer needed set back Inst.DefaultProgressMon = DefaultProgress

Note: in most cases Inst.DefaultProgressMon calls its methods in a thread that's not main - so synchronize when needed to update UI.

ok?

-žarko
Sascha Wächterowitz
User
Posts: 3
Joined: Tue Oct 12, 2021 8:17 am

Re: Request: IPogressCallback for various op.'s

Post by Sascha Wächterowitz »

Hi žarko,

thank you very much for the answer and alternative approach. Much appreciated.

Best
Sascha
User avatar
Paul - Tracker Supp
Site Admin
Posts: 6813
Joined: Wed Mar 25, 2009 10:37 pm
Location: Chemainus, Canada
Contact:

Request: IPogressCallback for various op.'s

Post by Paul - Tracker Supp »

:)
Best regards

Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com
Post Reply