op.document.optimize -> e.operBeforeExecute/e.operExecuted == op.openDoc SOLVED
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.
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.
-
- User
- Posts: 1372
- Joined: Thu Sep 05, 2019 12:35 pm
op.document.optimize -> e.operBeforeExecute/e.operExecuted == op.openDoc
Hi Support,
I'm trying to catch the moment when "op.document.optimize" does its work.
I'm handling e.operBeforeExecute and e.operExecuted events.
Seems that op.document.optimize is not caught (not passed), rather "op.openDoc" is reported when IOperation.Do is executed.
By design, or?
Further, when op.openDoc is caught after calling IOperation.Do(op.document.optimize) - the "Input" parameter is some interface but none of IAFS_Name, IAFS_File, IString or IStream. What is it?
-žarko
I'm trying to catch the moment when "op.document.optimize" does its work.
I'm handling e.operBeforeExecute and e.operExecuted events.
Seems that op.document.optimize is not caught (not passed), rather "op.openDoc" is reported when IOperation.Do is executed.
By design, or?
Further, when op.openDoc is caught after calling IOperation.Do(op.document.optimize) - the "Input" parameter is some interface but none of IAFS_Name, IAFS_File, IString or IStream. What is it?
-žarko
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: op.document.optimize -> e.operBeforeExecute/e.operExecuted == op.openDoc
Hello zarkogajic,
As that operation is from plugin - the default begin/end wrapper is missing - thus you can't catch the events. Also, the interface that is being passed to the op.openDoc is IString.
Cheers,
Alex
As that operation is from plugin - the default begin/end wrapper is missing - thus you can't catch the events. Also, the interface that is being passed to the op.openDoc is IString.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 1372
- Joined: Thu Sep 05, 2019 12:35 pm
Re: op.document.optimize -> e.operBeforeExecute/e.operExecuted == op.openDoc
Hi Alex,
However, when programmatically executing (IPXV_Inst.CreateOp) IOperation(op.document.optimize).Do, the "Input" in e.operBeforeExecute/op.openDoc is *not* IString (nor any of IAFS_Name, IAFS_File, IStream).
-žarko
It is so when using "Save As Optimized...", the "Input" in e.operBeforeExecute/op.openDoc *is* IString (a file name under Temp folder).Also, the interface that is being passed to the op.openDoc is IString.
However, when programmatically executing (IPXV_Inst.CreateOp) IOperation(op.document.optimize).Do, the "Input" in e.operBeforeExecute/op.openDoc is *not* IString (nor any of IAFS_Name, IAFS_File, IStream).
-žarko
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: op.document.optimize -> e.operBeforeExecute/e.operExecuted == op.openDoc
Hello zarkogajic,
We've added the e.operBeforeExecute/e.operExecuted events for the optimize operation - you will be able to do what you require. The fix will be available in the V9 version that should be out in a month or so.
Cheers,
Alex
We've added the e.operBeforeExecute/e.operExecuted events for the optimize operation - you will be able to do what you require. The fix will be available in the V9 version that should be out in a month or so.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 1372
- Joined: Thu Sep 05, 2019 12:35 pm
Re: op.document.optimize -> e.operBeforeExecute/e.operExecuted == op.openDoc
Thanks Alex,
That's great!
Would e.operExecuted be fired before or after the file has been saved to the file system? (the later is more preferable )
-žarko
That's great!
Would e.operExecuted be fired before or after the file has been saved to the file system? (the later is more preferable )
-žarko
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: op.document.optimize -> e.operBeforeExecute/e.operExecuted == op.openDoc
Hello zarkogajic,
This would be before the document is saved. Basically, you will catch the e.operExecuted event and then you have two choices:
1) Work with that document structure directly via our API and do the needed stuff to make it a linearized pdf file.
2) Get the document's IAFS_Name, close the document (so that the file won't be blocked), do your stuff with the 3rd party tools, open that document with the saved IAFS_Name and put it's object into the operation Output in place of the old one.
Note, that when registering the EventHandler, you should not use the EventHandler_SyncCall, becuse this will block the main thread of the Control while you are working with the file.
Cheers,
Alex
This would be before the document is saved. Basically, you will catch the e.operExecuted event and then you have two choices:
1) Work with that document structure directly via our API and do the needed stuff to make it a linearized pdf file.
2) Get the document's IAFS_Name, close the document (so that the file won't be blocked), do your stuff with the 3rd party tools, open that document with the saved IAFS_Name and put it's object into the operation Output in place of the old one.
Note, that when registering the EventHandler, you should not use the EventHandler_SyncCall, becuse this will block the main thread of the Control while you are working with the file.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 1372
- Joined: Thu Sep 05, 2019 12:35 pm
Re: op.document.optimize -> e.operBeforeExecute/e.operExecuted == op.openDoc
HI Alex,
Thanks. I'll have to work with your proposed option (2).
I'll close the topic and wait for the new release including those to events ...
-žarko
Thanks. I'll have to work with your proposed option (2).
I'll close the topic and wait for the new release including those to events ...
-žarko
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
op.document.optimize -> e.operBeforeExecute/e.operExecuted == op.openDoc
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 1372
- Joined: Thu Sep 05, 2019 12:35 pm
Re: op.document.optimize -> e.operBeforeExecute/e.operExecuted == op.openDoc
Hi Support,
Now in V9, I can catch "e.operExecuted" for "op.document.optimize", so I'm reopening this topic...
Also, the Output parameter at this moment does have something but that something is not IAFS_Name - what is it ? (the Help system states Output is not used)
When does your optimization actually happen? As I would need to call my 3rdparty linearization code after you do optimization (as otherwise I think your optimization would remove linearization)...
-žarko
Now in V9, I can catch "e.operExecuted" for "op.document.optimize", so I'm reopening this topic...
What I see is that "e.operExecuted" for "op.document.optimize" happens before the SaveAs dialog prompts for the file name to save.This would be before the document is saved. Basically, you will catch the e.operExecuted event and then you have two choices:
2) Get the document's IAFS_Name, close the document (so that the file won't be blocked), do your stuff with the 3rd party tools, open that document with the saved IAFS_Name and put it's object into the operation Output in place of the old one.
Also, the Output parameter at this moment does have something but that something is not IAFS_Name - what is it ? (the Help system states Output is not used)
When does your optimization actually happen? As I would need to call my 3rdparty linearization code after you do optimization (as otherwise I think your optimization would remove linearization)...
I'm not sure why would I need an EventHandler for the above?Note, that when registering the EventHandler, you should not use the EventHandler_SyncCall, becuse this will block the main thread of the Control while you are working with the file
-žarko
-
- User
- Posts: 1372
- Joined: Thu Sep 05, 2019 12:35 pm
Re: op.document.optimize -> e.operBeforeExecute/e.operExecuted == op.openDoc
Hi Support,
I've figured out the order of events here .... and I think I know now how to do what I'm after ...
-ž
I've figured out the order of events here .... and I think I know now how to do what I'm after ...
-ž
-
- User
- Posts: 1372
- Joined: Thu Sep 05, 2019 12:35 pm
Re: op.document.optimize -> e.operBeforeExecute/e.operExecuted == op.openDoc
Hi Support,
Here's my last attempt to try to linearize a file as a part of optimization operation...
The "e.document.afterSave" gets raised for Save and Save As but also for Save Copy As. But, not for Save As Optimized.
May I ask you to include/raise the "e.document.afterSave" event also for the "Save As Optimized" command - once the document is saved to file system.
Being able to react on "e.document.afterSave" for optimized documents would then give me a moment to do my stuff to the file....
p.s.
I know optimization works on Core Documents - and there may be no IPXVDocument when running the operation - but in case there is (when optimizing an IPXV_Document loaded in MainFrame) - e.document.afterSave could be raised from it and then I could get my hands on the optimized file from IPXV_DocSaveEvent.Dest property.
-žarko
Here's my last attempt to try to linearize a file as a part of optimization operation...
The "e.document.afterSave" gets raised for Save and Save As but also for Save Copy As. But, not for Save As Optimized.
May I ask you to include/raise the "e.document.afterSave" event also for the "Save As Optimized" command - once the document is saved to file system.
Being able to react on "e.document.afterSave" for optimized documents would then give me a moment to do my stuff to the file....
p.s.
I know optimization works on Core Documents - and there may be no IPXVDocument when running the operation - but in case there is (when optimizing an IPXV_Document loaded in MainFrame) - e.document.afterSave could be raised from it and then I could get my hands on the optimized file from IPXV_DocSaveEvent.Dest property.
-žarko
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: op.document.optimize -> e.operBeforeExecute/e.operExecuted == op.openDoc
Hello zarkogajic,
Theoretically this can be added - but will need to consult with Vasyl first.
Cheers,
Alex
Theoretically this can be added - but will need to consult with Vasyl first.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 1372
- Joined: Thu Sep 05, 2019 12:35 pm
Re: op.document.optimize -> e.operBeforeExecute/e.operExecuted == op.openDoc
Hi Alex,
Thanks, that would be great!
-ž
Thanks, that would be great!
-ž
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: op.document.optimize -> e.operBeforeExecute/e.operExecuted == op.openDoc
Hi zarkogajic.
In the new upcoming build you will be able to catch the new "e.document.preSaveOptimizedData" event and get the IPXV_DocPreSaveOptimizedDataEvent interface from the IEvent argument in OnEvent callback. The short description of that interface:
TempOptimizedDoc - is the temp. core-document that can be used for additional modifications you need and before saving to the destination file. Also you may use the TempOptimizedDoc.SrcInfo.File to read/write it (but do not use methods of TempOptimizedDoc-object after writing to the File).
OptimizationOpts - contains all optimization-options used by user
DestFileName - the file name specified by user, you may change it.
HTH.
In the new upcoming build you will be able to catch the new "e.document.preSaveOptimizedData" event and get the IPXV_DocPreSaveOptimizedDataEvent interface from the IEvent argument in OnEvent callback. The short description of that interface:
Code: Select all
uuid(45BF8A5F-296C-44D4-9DB4-E04F04EF501B)
IPXV_DocPreSaveOptimizedDataEvent
{
[get] IPXC_Document TempOptimizedDoc;
[get] ICab OptimizationOpts;
[get, set] IAFS_Name DestFileName;
[get] HANDLE_T WndParent;
[get] IProgressMon Progress;
};
OptimizationOpts - contains all optimization-options used by user
DestFileName - the file name specified by user, you may change it.
HTH.
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
-
- User
- Posts: 1372
- Joined: Thu Sep 05, 2019 12:35 pm
Re: op.document.optimize -> e.operBeforeExecute/e.operExecuted == op.openDoc
Hi Vasyl,
Thanks - looks good.
Btw, still, please fire ".document.afterSave" for optimized saved documents...
-ž
Thanks - looks good.
Btw, still, please fire ".document.afterSave" for optimized saved documents...
-ž
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: op.document.optimize -> e.operBeforeExecute/e.operExecuted == op.openDoc
Hello zarkogajic,
Spoke with Vasyl, and he said that's it's too much work to do and to risky to inject a document.afterSave event for the current optimization operation logic.
We fear that something can be broken along the way and as this is an old and battle hardened operation, let's leave it as is. Basically these events that Vasyl gave you will do all of the stuff that you require.
Cheers,
Alex
Spoke with Vasyl, and he said that's it's too much work to do and to risky to inject a document.afterSave event for the current optimization operation logic.
We fear that something can be broken along the way and as this is an old and battle hardened operation, let's leave it as is. Basically these events that Vasyl gave you will do all of the stuff that you require.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 1372
- Joined: Thu Sep 05, 2019 12:35 pm
Re: op.document.optimize -> e.operBeforeExecute/e.operExecuted == op.openDoc
Hi Alex,
ok, thanks, I hear ya.
Yes, hopefully IPXV_DocPreSaveOptimizedDataEvent should be enough ... I'm downloading 353 now and will do test in the coming days...
-ž
ok, thanks, I hear ya.
Yes, hopefully IPXV_DocPreSaveOptimizedDataEvent should be enough ... I'm downloading 353 now and will do test in the coming days...
-ž
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
op.document.optimize -> e.operBeforeExecute/e.operExecuted == op.openDoc
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 1372
- Joined: Thu Sep 05, 2019 12:35 pm
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: op.document.optimize -> e.operBeforeExecute/e.operExecuted == op.openDoc
Hello zarkogajic,
Vasyl replied you there.
Cheers,
Alex
Vasyl replied you there.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ