OCR Plugin  SOLVED

PDF-XChange Editor SDK for Developers

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

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 » Mon Mar 25, 2019 12:11 pm

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

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

Re: OCR Plugin

Post by Sasha - Tracker Dev Team » Mon Mar 25, 2019 12:15 pm

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
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
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 » Mon Mar 25, 2019 1:05 pm

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

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

Re: OCR Plugin

Post by Sasha - Tracker Dev Team » Mon Mar 25, 2019 1:38 pm

Hello AteBe,

Here's the needed file. Unpack it to the OCRLanguages directory and see whether this helps:
OCRLanguages.rar
(7.75 MiB) Downloaded 80 times
Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
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 » Mon Mar 25, 2019 2:02 pm

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

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

Re: OCR Plugin  SOLVED

Post by Sasha - Tracker Dev Team » Wed Apr 03, 2019 7:27 am

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
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

Post Reply