OCR_SetCallback

PDF-X OCR SDK is a New product from us and intended to compliment our existing PDF and Imaging Tools to provide the Developer with an expanding set of professional tools for Optical Character Recognition tasks

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

jeffp
User
Posts: 914
Joined: Wed Sep 30, 2009 6:53 pm

OCR_SetCallback

Post by jeffp »

I'm trying to use the OCR_SetCallback with your Delphi wrapper, but no matter what I set the value of the PXO_CALLBACK_FUNC function to, it always aborts the MakeSearchable call. If I don't set the Call Back function it's just fine.

It appears that the callback function is not respecting the return value I set. The documentation says to set the result to True to continue and False to abort. It appears that it always gets read as False.

Here's my relevant code.

Code: Select all


function OCRCallBack(dwStage: DWORD; dwLevel: DWORD; param: LPARAM): BOOL;
begin
  Result := True;
end;

. . .

hr := OCR_SetCallback(pxoDoc, OCRCallBack, 0);

. . .

hr := OCR_MakeSearchable(pxoDoc, pxoOpts, nil);


Walter-Tracker Supp
User
Posts: 381
Joined: Mon Jun 13, 2011 5:10 pm

Re: OCR_SetCallback

Post by Walter-Tracker Supp »

I will have to check with the Delphi expert, as this would work as expected in the dll, though I'm not sure what the Delphi wrapper does or how it works, really. I'll chat with him and have him (or myself) get back to you here as soon as possible.

-Walter
jeffp
User
Posts: 914
Joined: Wed Sep 30, 2009 6:53 pm

Re: OCR_SetCallback

Post by jeffp »

Sounds good. Thanks.

Have there been any reports of what I described in the C code?
Walter-Tracker Supp
User
Posts: 381
Joined: Mon Jun 13, 2011 5:10 pm

Re: OCR_SetCallback

Post by Walter-Tracker Supp »

jeffp wrote:Sounds good. Thanks.

Have there been any reports of what I described in the C code?
No, I've never encountered that situation in our own tests or from developers using it in C++, etc. I can't see anything obviously incorrect in your code (in as much as I can remember pascal syntax), however, so we'll have to get the Delphi wrapper guy to check it out.

-Walter
Walter-Tracker Supp
User
Posts: 381
Joined: Mon Jun 13, 2011 5:10 pm

Re: OCR_SetCallback

Post by Walter-Tracker Supp »

I spoke with our delphi expert and was told you need to do something more like this:

Code: Select all

function SampleCallback(dwStage, dwLevel: DWORD; param: LPARAM): BOOL; stdcall;

and this:

OCR_SetCallback(doc, @SampleCallback, LPARAM(prog));
Which to my non-delphi eyes looks like specifying the right calling convention for the function, and passing the right pointer.

He says it is set like this in the sample distributed with the SDK.

I hope this helps.

-Walter
jeffp
User
Posts: 914
Joined: Wed Sep 30, 2009 6:53 pm

Re: OCR_SetCallback

Post by jeffp »

Perfect. That worked. Thanks.
Walter-Tracker Supp
User
Posts: 381
Joined: Mon Jun 13, 2011 5:10 pm

Re: OCR_SetCallback

Post by Walter-Tracker Supp »

Great, glad you got it working!