OCR Plugin  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
AteBe
User
Posts: 63
Joined: Thu Dec 06, 2018 7:02 am

OCR Plugin

Post by AteBe »

Hallo Alex,

I successfully installed the OCR plugin with the following code.

Code: Select all

iControlSite = new OleControlSiteEx(frame, SWT.NONE, "PDFXEdit.PXV_Control.1");
iControlSite.doVerb(OLE.OLEIVERB_SHOW);
iControlSite.doVerb(OLE.OLEIVERB_UIACTIVATE);
iCtrl = new IPXV_Control(iControlSite.getPointerToUnknown());
iInst = iCtrl.Inst();
iInst.StartLoadingPlugins();
iInst.AddPluginFromFile("C:\\Program Files (x86)\\Tracker Software\\Editor SDK\\Bin\\Plugins.x64\\OCRPlugin.pvp");
iInst.FinishLoadingPlugins();
Plugin2.png


Nevertheless, the corresponding menu item is not displayed to me.
OrcMenu.png


In addition, I try to open the OCR dialog box with the following code:

Code: Select all

iControlSite = new OleControlSiteEx(frame, SWT.NONE, "PDFXEdit.PXV_Control.1");
iControlSite.doVerb(OLE.OLEIVERB_SHOW);
iControlSite.doVerb(OLE.OLEIVERB_UIACTIVATE);
iCtrl = new IPXV_Control(iControlSite.getPointerToUnknown());
iInst = iCtrl.Inst();

IOperation operation = null;
ICabNode options = null;
int nID = iInst.Str2ID("op.document.OCRPages", false);
operation = iInst.CreateOp(nID);
operation.Params().Root().SetUnknown("Input", getActiveDocument());
options = operation.Params().Root().Item(new VARIANT("Options"));
options.SetString("PagesRange.Type", "All");
options.SetInt("OutputType", 0);
options.SetInt("OutputDPI", 300);
options.SetString("PagesRange.Type", "All");
operation.Do(0);
As a result, however, I get the following error message:

Failed loading language 'eng'
Tesseract couldn't load any languages!
Error opening data file ././eng_pxvocr.dat
Please make sure the TESSDATA_PREFIX environment variable is set to the parent directory of your "tessdata" directory.


Can you tell me what I'm doing wrong.

Thanks

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

Re: OCR Plugin

Post by Sasha - Tracker Dev Team »

Hello AteBe,

For starters, if you want to use plugins, make sure that you have created the IPXV_Inst first, initialize it, load plugins and then create the control.
Also, check out this topic :
viewtopic.php?p=97913#p97913

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
AteBe
User
Posts: 63
Joined: Thu Dec 06, 2018 7:02 am

Re: OCR Plugin

Post by AteBe »

Hello Alex,

I already read the link you sent me and created my code according to this example.
I also call the functions in the order you describe

Loading the plugin has indeed worked (see picture above).
Nevertheless, the corresponding menu item is not displayed (see picture above).

When I try to call the OCR dialog via a button with my code (see my code above), I get the described Error message.

Failed loading language 'eng'
Tesseract couldn't load any languages!
Error opening data file ././eng_pxvocr.dat
Please make sure the TESSDATA_PREFIX environment variable is set to the parent directory of your "tessdata" directory.


Is there anything else I have to consider.

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

Re: OCR Plugin

Post by Sasha - Tracker Dev Team »

Hello AteBe,

Here's the needed file. Unpack it to the OCRLanguages directory and see whether this helps:
OCRLanguages.rar
(7.75 MiB) Downloaded 116 times
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
AteBe
User
Posts: 63
Joined: Thu Dec 06, 2018 7:02 am

Re: OCR Plugin

Post by AteBe »

Hello Alex,

the OCR recognition is now working, but only in the background.
The OCR dialog, in which one e.g. can select the language is not displayed.
How can I call the OCR dialog and the progress bar with my Code ?

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

Re: OCR Plugin  SOLVED

Post by Sasha - Tracker Dev Team »

Hello AteBe,

There was a small fix done in the FinishLoadingPlugins method - from the next release the OCR commands will be added into the needed places when this method is called.
The next release should be available in a few days.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply