VB.NET Visual Studio 2008 Example

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

kman
User
Posts: 14
Joined: Thu May 08, 2008 8:15 pm

VB.NET Visual Studio 2008 Example

Post by kman »

I'm having difficulty getting a working example. The one provided is in either c or vb6. I need a VB.NET example.
I converted the vb6 "OcrVbExample" to VB.NET and went through the conversion errors as best I could.
It compiles and seems to be processing the pdf in order to produce a searchable pdf with image overlay.
However no text is searchable in the output.pdf

I have ocrtools.dll in my project \bin directory.
It's Fileversion=1.0.0009.0001

The options.datapath is C:\Program Files\Tracker Software\PDF-XChange PRO 4 SDK\Examples\OCRLanguages\
Where I have
eng.lng
eng_pxvocr.dat
osd_pxvocr.dat
In the directory C:\Program Files\Tracker Software\PDF-XChange PRO 4 SDK\Examples\OCRLanguages\ocrdats

When I run the program it systematically displays the following:
Page 0 Rasterizing 25.00%
Page 0 Auto-rotating 50.00%
Page 0 Running OCR 75.00%
Page 0 Placing Image 100.00%

But in the end the output.pd seems to only be an image.
You do not have the required permissions to view the files attached to this post.
Walter-Tracker Supp
User
Posts: 381
Joined: Mon Jun 13, 2011 5:10 pm

Re: VB.NET Visual Studio 2008 Example

Post by Walter-Tracker Supp »

Can you please provide us with a sample input and output? Have you tried it with more than one file to ensure that it is not a problem with the input you tested on?

Thank you!
-Walter
kman
User
Posts: 14
Joined: Thu May 08, 2008 8:15 pm

Re: VB.NET Visual Studio 2008 Example

Post by kman »

Yes I have tried various input pdfs with same results.
I have uploaded the cleanest scan I have scantest4.pdf and it would not ocr with my code either.
It will ocr just fine using the pdfxchange viewer ocr function.
I suspect that the ocr module is not utilizing the language file properly in order to match characters.
You do not have the required permissions to view the files attached to this post.
Walter-Tracker Supp
User
Posts: 381
Joined: Mon Jun 13, 2011 5:10 pm

Re: VB.NET Visual Studio 2008 Example

Post by Walter-Tracker Supp »

We will look into this and get back to you shortly.

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

Re: VB.NET Visual Studio 2008 Example

Post by Walter-Tracker Supp »

I was unable to get your example to compile (because it is missing a few project resource files to reproduce the right form layout, event managers, etc), however I have created a simpler VB.net example that does work for me. I changed how String types are represented in the struct PXO_Options by changing String types to Integer (for passing pointers) in OcrCommon.vb. I added a function that converts String types into Integer pointers as well (VarPtrAny()). While I am not a VB.net expert by any means, I do believe that you cannot pass String types properly in a struct (like PXO_Options)... so passing pointers to strings appears to be a good workaround. Please be sure to create String variables and pass the pointer to those rather than trying to pass string literals.

ie,

Code: Select all

Dim datapath as String
datapath = "z:\datadir"
options.dataPath = VarPtrAny(datapath) 
should be okay, but do not use:

Code: Select all

options.dataPath = VarPtrAny("z:\datadir")
Also, take care not to alter the string between creating the pointer with VarPtrAny() and running OCR_MakeSearchable(). If the user might change the data directory after options have been set, you might need to reinitialize it (set options.dataPath again) with the right event trap.

I'm attaching the example in the next reply here.
Walter-Tracker Supp
User
Posts: 381
Joined: Mon Jun 13, 2011 5:10 pm

Re: VB.NET Visual Studio 2008 Example

Post by Walter-Tracker Supp »

The data directory, input and output filenames are hard coded in the source code, so this is obviously a very barebones application. Please modify to suit your tastes. I'm sorry that I could not come up with anything more exciting, but I am a C++ developer and the VB.net experts are very busy with pressing deadlines so I have been left to fend for myself here.

I have, however, verified that it does work and so should provide a good starting point for your own exploits.

-Walter
You do not have the required permissions to view the files attached to this post.
kman
User
Posts: 14
Joined: Thu May 08, 2008 8:15 pm

Re: VB.NET Visual Studio 2008 Example

Post by kman »

Walter,
You rock!!! That works perfectly and is exactly what I needed.
Off to the races now.

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

Re: VB.NET Visual Studio 2008 Example

Post by Walter-Tracker Supp »

Good to hear. Let us know if you have further problems.


-Walter