Page 1 of 1

Tiff to Searchable PDF

Posted: Mon Apr 30, 2012 1:41 pm
by xtreme1
I need to convert thousands of tiff and other image formats to searchable PDF's. Can you provide some sample on how to accomplish this using C#?

Re: Tiff to Searchable PDF

Posted: Mon Apr 30, 2012 2:32 pm
by Tracker Supp-Stefan
Hi xtreme1,

It's not currently possible to directly OCR an image using our OCR SDK:
https://forum.pdf-xchange.com/ ... 42&t=12666

But it's certainly possible to create a PDF file from image(s) - e.g. using the Tools SDK, and then call the OCR to add the layer of searchable text in your files.

We do not have a single example that will do both - but if you download our PDF XChange Pro SDK:
https://www.pdf-xchange.com/product ... ge-pro-sdk
You will find samples for both PDF Creation, as well as for OCRing existing PDF files.

Best,
Stefan

Re: Tiff to Searchable PDF

Posted: Tue May 01, 2012 3:49 pm
by xtreme1
Do you have samples in C#?

Re: Tiff to Searchable PDF

Posted: Tue May 01, 2012 4:00 pm
by Tracker Supp-Stefan
Hi xtreme1,

Yes we do :)

Cheers,
Stefan

Re: Tiff to Searchable PDF

Posted: Tue May 01, 2012 4:43 pm
by xtreme1
Okay... Can you please share?

I downloaded the Pro SDK and the only OCR examples you have are C, Delphi and VB.

Thanks for your help....

Rob

Re: Tiff to Searchable PDF

Posted: Tue May 01, 2012 6:30 pm
by Walter-Tracker Supp
Actually we do not currently have an OCR C# sample, however this is something we are hoping to add in the next little while. I realize this does not help you much, as you are looking for a solution right now, but we added the OCR SDK as a free bonus feature a couple of months ago and as such have not added as many examples as some of our other projects have (although, as with all our products, we continue to resolve critical bugs in a timely manner). We have a much more elaborate solution coming out in the next version of the SDKs, sometime later in the year.

Meanwhile, if you were industrious you could implement a C# wrapper by following the existing examples for the other SDKs. It really would not be much difficulty to look at the C header files and create the C# implementation by following the example for, e.g., the Simple Viewer DLL. It would probably only take a day or two to do this.

But this will be up to you to implement unless you are content to wait a few weeks (as we are quite busy finalizing our new major version of the PDF XChange Viewer and our development resources are heavily focused).

Re: Tiff to Searchable PDF

Posted: Wed May 02, 2012 1:18 pm
by xtreme1
Thanks...I need to determine if OCR library is the right solution. Can you you provide a little more guidance on how to create the wrapper. Which library files and header files to include?

thanks,

Rob

Re: Tiff to Searchable PDF

Posted: Wed May 02, 2012 5:06 pm
by Walter-Tracker Supp
xtreme1 wrote:Thanks...I need to determine if OCR library is the right solution. Can you you provide a little more guidance on how to create the wrapper. Which library files and header files to include?

thanks,

Rob
The C++ header files, ocrtools.h and ocr_types.h, contain the structures and functions you need to declare in C#.

If you look at the C# example in (PDF Tools PRO SDK InstallationDirectory)\Examples\SDKExamples\C#Examples\PDFXC_Funcs.cs, you should see roughly how to implement them in C#.

However I will see if we can accellerate this and put something out in the next day or two. I will respond back in an hour or so with a verdict on whether we can divert some resources to this or not.

Re: Tiff to Searchable PDF

Posted: Wed May 02, 2012 7:15 pm
by Walter-Tracker Supp
We are working on this now and should hope to have a demo and wrapper ready in the next day or so.

-Walter

Re: Tiff to Searchable PDF

Posted: Thu May 03, 2012 12:31 am
by Walter-Tracker Supp
A preliminary version of the C# demo is complete. Please find it attached.

This is not an official release, and won't be included in the SDK installer until we have had a chance to more thoroughly test it. Please ensure you test it rigorously before putting it into production, or wait until we have officially supported it (when we put it in the downloadable installer for the SDK).

Re: Tiff to Searchable PDF

Posted: Thu May 03, 2012 1:14 pm
by xtreme1
I am receiving an missing DLL error:
Unable to load DLL 'ocrtools': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Re: Tiff to Searchable PDF

Posted: Thu May 03, 2012 4:16 pm
by Walter-Tracker Supp
xtreme1 wrote:I am receiving an missing DLL error:
Unable to load DLL 'ocrtools': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Yes, you need to download the SDK and copy the DLL (ocrtools.dll, or ocrtools-x64.dll (64 bit)) to your project executable directory. If you use the 64 bit DLL you need to either rename it to ocrtools.dll, or change the import statements in the C# source file that declares the dll-exported functions..

ie, to use the ocrtools-x64.dll binary, in PDFXOCR_Funcs.cs, change all instances of:

Code: Select all

        [DllImport("ocrtools")] 
to

Code: Select all

        [DllImport("ocrtools-x64")] 
We may just change the source to handle this automatically. For now the easiest way is to just rename the 64 bit binary if you are creating a 64 bit build.

The attachment is only the example code for the C# project, not the executable dll.

Re: Tiff to Searchable PDF

Posted: Thu May 03, 2012 4:51 pm
by xtreme1
:D Thanks... I was able to locate it and use the sample code to OCR one of our docs to searchable PDF. I appreciate the support...

Re: Tiff to Searchable PDF

Posted: Thu May 03, 2012 5:22 pm
by Walter-Tracker Supp
No problem. It's been on the TO-DO list for awhile and your request was the final push we needed.

We haven't yet tested all the functionality in the wrapper, so if you come upon any problems please contact us and we will fix them.

We will be conducting our own testing over the next week or so, and will update the main SDK installer once that is done.

-Walter

Re: Tiff to Searchable PDF

Posted: Thu May 10, 2012 8:54 pm
by Walter-Tracker Supp
Please note that I have found a bug in the wrapper; an "int" type has been used for some pointers, where in fact an IntPtr type is needed to ensure full interoperability for both 32 and 64 bit versions. I am making the changes and will post an update shortly.

Re: Tiff to Searchable PDF

Posted: Thu May 10, 2012 10:52 pm
by Walter-Tracker Supp
Here is the fixed C# demo application.

Re: Tiff to Searchable PDF

Posted: Sat Dec 29, 2012 1:54 am
by xtreme1
I have started to work with the ocrtools with C# and have found that only the first 2 pages get saved even though the callback appears to be working on all pages. This occurs with the 32 bit version of the ocrDemoCsharp.
Is there something missing in the demo that only saves the 1st 2 pages? :?

Re: Tiff to Searchable PDF

Posted: Sun Dec 30, 2012 3:56 am
by John - Tracker Supp
Yes - in the demo for the SDK, you can only save 2 pages - you need a full license to be able to use the SDK and save all the results.

Also - please note you are posting in the drivers forum - for the end user product - please post in the correct Developer SDK forum (e.g here ;)

https://forum.pdf-xchange.com/ ... m.php?f=42

to ensure the correct staff member answers your post promptly
thanks

Re: Tiff to Searchable PDF

Posted: Sun Dec 30, 2012 5:18 pm
by xtreme1
I do have a license

:?

Re: Tiff to Searchable PDF

Posted: Sun Dec 30, 2012 10:56 pm
by Paul - Tracker Supp
Hi xtreme1,

don't post your serial number here, but do tell me if you are able to do other things that requires a license without getting water marks. that would be a sign that the serial key is not being passed properly and that your app is actually running in trial mode.

If it's just the 2 page limitation that is an issue for you then it might be more than just a licensing issue. Can you confirm that your app is passing the serial key properly for other functionality?

regards

Re: Tiff to Searchable PDF

Posted: Mon Dec 31, 2012 2:22 am
by John - Tracker Supp
What Paul has omiited to tell you is the OCR SDK requires you use a 'live' DLL to function without the trial limitations.

Please email support@pdf-xchange.com with your full license details - if you have the full PDF-XChange PRO SDK we will provide you with the necessary details - please note - only the full PDF-XChange PRO SDK includes the use of the OCR SDK, PDF-Tools and Drivers SDK's for example do not !

HTH

Re: Tiff to Searchable PDF

Posted: Mon Dec 31, 2012 3:08 pm
by xtreme1
I've sent my license information to support... Please let me know what I need to do to get the "live" ocrtools dll....

Thanks,

Rob :D

Re: Tiff to Searchable PDF

Posted: Mon Dec 31, 2012 5:17 pm
by John - Tracker Supp
Hi Rob,

I believe a colleague has already dealt with this - if not - please do come back.

Thanks

Re: Tiff to Searchable PDF

Posted: Wed Feb 27, 2013 9:08 pm
by MWisniewski
Hi, I am trying to dowload OCRDemoCsharp.7z file and its not in the correct format. Can anyone please help, i am trying to run the demo example code for the OCR. Thanks. the one i got from the SDK 5.0. complains about the dll not found. Thanks.

Re: Tiff to Searchable PDF

Posted: Wed Feb 27, 2013 9:45 pm
by Walter-Tracker Supp
MWisniewski wrote:Hi, I am trying to dowload OCRDemoCsharp.7z file and its not in the correct format. Can anyone please help, i am trying to run the demo example code for the OCR. Thanks. the one i got from the SDK 5.0. complains about the dll not found. Thanks.
OCRDemoCSharp.7z is a 7-zip file - you will need 7-Zip from http://www.7-zip.org/ to uncompress it. However the contents are the same as the demo included in the SDK.

There are two builds of the OCR DLL (which is a native / non-managed DLL created in C++, incidentally - ie., not a .NET assembly) - one for 64 bit and one for 32 bit. They are found in:

(installpath)\PDF-XChange PRO 5 SDK\Examples\Bin

and

(installpath)\PDF-XChange PRO 5 SDK\Examples\Bin.x64

All the DLL's functions are imported by PDFXOCR_Funcs.cs using the unmanaged DLL import attribute [DllImport("ocrtools")]. Because of the way it is specified it searches for "ocrtools.dll" in the current search path (usually the executable's running directory - ie the location of OCRDemoCSharp.exe).

There are two ways to set it up so that it runs for you.

1. You can modify the path "ocrtools" to point to a specific DLL:

For example, for 64 bit, change the DllImport attributes to: [DllImport("C:\\Program Files\\Tracker Software\\PDF-XChange PRO 5 SDK\\Examples\\Bin.x64\\ocrtools-x64.dll")]

2. You can copy the DLL to the search path (ie, the built executable's directory).

Where this is will depend on how you configure your build environment, but on my system, using the default installation of PDF Tools SDK 5, and in x64 Debug configuration, it is:

C:\Program Files\Tracker Software\PDF-XChange PRO 5 SDK\Examples\OcrSDKExamples\C#Examples\OCRDemoCsharp\OCRDemoCsharp\bin\x64\Debug\

You'll have to make sure to copy the right DLL (64bit or 32bit), and possibly rename it to ocrtools.dll, or change the PDFXOCR_Funcs.cs import attributes to reflect the use of a 64 bit DLL if needed - ie: [DllImport("ocrtools-x64")].




Hope this helps.

Re: Tiff to Searchable PDF

Posted: Mon Mar 04, 2013 4:20 pm
by MWisniewski
Thanks so much. Your solution :wink: worked.

Re: Tiff to Searchable PDF

Posted: Mon Mar 04, 2013 4:43 pm
by Tracker Supp-Stefan
:)