IPXC_Document.PlaceHeadersAndFooters sporadic "unknow error" exception

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

IPXC_Document.PlaceHeadersAndFooters sporadic "unknow error" exception

Post by zarkogajic »

Hi Support,

This will be close-to-not-possible to catch - but I'm hoping you already maybe are aware of the issue.

I'm using PlaceHeadersAndFooters (all document pages) inside a custom IOperation, running multiple such operations via AsyncDo: at the same time couple of documents are being processed and the PlaceHeadersAndFooters does its work, each IOperation does the work on one file.

For test I've run the above on the same set of documents multiple times.

Sometimes, so cannot catch, PlaceHeadersAndFooters would fail with (IAUX_Inst.FormatHRESULT) "unknow error" for some documents (not always the same).

If I open the resulting document(s) in EU Editor - I see the header/footer was applied on a number of pages (from the first page, not always the same number) and the remaining pages do not have the header/footer applied.

If I use Add Header/Footer from EU Editor for those particular documents - all ok.

If I run the same process (my code) the second time, all ok. The next time, again some documents are affected with "unknown error", and so on..

So, cannot catch, nor can reproduce.

Any idea (how to help you locate the cause of it)?

p.s.
No, cannot reproduce in FullDemo.
No, cannot give you a sample application as the code is massive and the error does not happen always.

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

Re: IPXC_Document.PlaceHeadersAndFooters sporadic "unknow error" exception

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

Can you reproduce the same behavior with the PlaceBackgrounds or PlaceWatermark method (for testing purposes)?

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

Re: IPXC_Document.PlaceHeadersAndFooters sporadic "unknow error" exception

Post by zarkogajic »

Hi Alex,

Will try and report back.

The worst thing is that in some runs no errors at all, in some errors.

Each run takes ~15 minutes - so takes time to let it run and wait for results...

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

Re: IPXC_Document.PlaceHeadersAndFooters sporadic "unknow error" exception

Post by zarkogajic »

Hi Alex,

Cannot reproduce any more .. so will close the topic...

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

IPXC_Document.PlaceHeadersAndFooters sporadic "unknow error" exception

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: IPXC_Document.PlaceHeadersAndFooters sporadic "unknow error" exception

Post by zarkogajic »

Hi Alex,

This again is occurring randomly :(

I've implemented ILogListener and wrapped the call to PlaceHeadersAndFooters with RegisterListener/UnregisterListener. Sadly, the OnLogMsg is never called - even though PlaceHeadersAndFooters throws "unknow error".

Is ILogListener designed to be used like this, or?

Btw,
Can you reproduce the same behavior with the PlaceBackgrounds or PlaceWatermark method (for testing purposes)?
Yes, tried with PlaceWatermark - and also sporadic throws ...



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

Re: IPXC_Document.PlaceHeadersAndFooters sporadic "unknow error" exception

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

The ILogListener is used only in Optimizer plugin and PDF/A plugin, from what I know.
Does this occur on random documents? For example, if you launch this for a 1000 times for some document - can it reoccur then?

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

Re: IPXC_Document.PlaceHeadersAndFooters sporadic "unknow error" exception

Post by zarkogajic »

Hi Alex,

Always testing on the same set of documents. Yes, on random documents, not always the same. Sometimes without any document being affected, sometimes more documents affected - so very very sporadic and not catchable.



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

Re: IPXC_Document.PlaceHeadersAndFooters sporadic "unknow error" exception

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

So basically, if doing the PlaceHeaderFooter for couple hundred of times on some document set can recreate this - I can try doing this.
Should this be multithreaded?
And also - a small code snippet if you can :)

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

Re: IPXC_Document.PlaceHeadersAndFooters sporadic "unknow error" exception

Post by zarkogajic »

Hi Alex,

Some more info:

When I used PlaceWatermark to test, the issue also appeared. But, if I set to place the watermark only on, for example, first 10 pages - no issue. So, seems like only when I want the Watermark or Header/Footer on all pages I can "reproduce" this.

Also, as stated initially, the reason for ex throw is not the number of pages. Sometimes some first pages are ok (rest not applied), sometimes some more pages are ok (rest not applied), sometimes on the same document, sometimes different...

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

Re: IPXC_Document.PlaceHeadersAndFooters sporadic "unknow error" exception

Post by zarkogajic »

Hi Alex,
So basically, if doing the PlaceHeaderFooter for couple hundred of times on some document set can recreate this - I can try doing this. Should this be multithreaded? And also - a small code snippet if you can
Uh, oh. no small code snippet I can give you , but here's what my code looks like:

* Have a custom IOperation implementation
* The Do method, beside 'other things', would call PlaceHeadersAndFooters
* - 'other things' include opening the document and saving it after header/footer applied (and some more stuff)

For ~100 different documents do:

1. Instantiate myOp IOperation implementation for each document
2. AsyncDo(myOp) -> so yes multithreaded, more MyOp's being run at the same time, each in its own thread, each working on one document
3. Wait For All

Note [3] : I have my own implementation how to wait for all.

I am safe guarding the call to PlaceHeadersAndFooters inside the Do() method so it does not "exit" to OnFinishOp (IPXV_AsyncDoCallback). I'm catching/handling the exception and allowing to save the document (to "safely" end MyOp).


After some more testing: I can say that this problem seems to happen, if it happens, on the same subset of documents.

So, say if I have documents a,b,c,d,e,f,g,h,i,j,k,l,m,n,o.

The problem always happens on the same subset meaning that the problem seems to happen for documents in subset c,d,e,f,g,h. Sometimes none will be affected from that group. Sometimes c,f,g. Sometimes e,f,h. etc.

So, must be something with those documents.

However, when I take document by document and do (the same params) PlaceHeadersAndFooters - always all is ok. Even if I do that via AsyncDoAndWaitForFinish (so different thread but one by one).

And also, if of value: 32bit app.

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

Re: IPXC_Document.PlaceHeadersAndFooters sporadic "unknow error" exception

Post by Sasha - Tracker Dev Team »

Hello zarkogajic,

We'll try implementing such a project and see whether we can recreate this one.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
RMan
User
Posts: 221
Joined: Tue Jul 02, 2013 10:06 pm

Re: IPXC_Document.PlaceHeadersAndFooters sporadic "unknow error" exception

Post by RMan »

Are you creating your operation options objects once before the loop or each time inside of the loop?

It seams like I remember coming across a bug where if you defined it before the loop that it would cause the HeaderAndFooters and Bates Numbering to fail sometimes but if you defined them each time inside of the loop it worked.

Doing something like this worked

For

Dim oOp As PDFXEditCtl.IOperation
Set oOperation = Me.PDFEditor.Inst.CreateOp(...)
Dim oOptions As PDFXEditCtl.ICabNode
Set oOptions = oOperation.Params.Root("Options")
Dim oInput As PDFXEditCtl.ICabNode
Set oInput = Op.Params.Root("Input")
....
Call Me.PDFEditor.Inst.AsyncDoAndWaitForFinish(oOp, opExecFlags)

Set oInput = Nothing
Set oOptions = Nothing
Set oOperation = Nothing

Next


But trying to define the options once would not work always.

Dim oOp As PDFXEditCtl.IOperation
Set oOperation = Me.PDFEditor.Inst.CreateOp(...)
Dim oOptions As PDFXEditCtl.ICabNode
Set oOptions = oOperation.Params.Root("Options")
Dim oInput As PDFXEditCtl.ICabNode
Set oInput = Op.Params.Root("Input")
For
....
Call Me.PDFEditor.Inst.AsyncDoAndWaitForFinish(oOp, opExecFlags)

Next
Set oInput = Nothing
Set oOptions = Nothing
Set oOp = Nothing
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2351
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: IPXC_Document.PlaceHeadersAndFooters sporadic "unknow error" exception

Post by Vasyl-Tracker Dev Team »

Hi RMan.

The problem may occur when the implementation of operation-object creates and uses private and temporary data inside its Do(). And when Do() is finished - such temp. data must go away to make the state and operation-object clear and ready for the following Do() calls. But seems that this is not true for some operations, and they may still keep some internal data, which may affect the next calls of Do(). So, could you please let us know which operations are failing in this scenario?

Cheers.
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.
Post Reply