I have an image on which I have to perform two processes:
1) Convert it to PDF.
2) Perform a text extraction to a txt file.
So I create a single ImageDocument.
I then create a FRDocument adding the ImageDocument to it and perform the PDF conversion (DocumentConversion_Accuracy): everything works well.
I then create another FRDocument adding my ImageDocument to perform the text extraction (TextExtraction_Accuracy) -> I get an exception:
com.abbyy.FREngine.EngineException: Invalid pointer at com.abbyy.FREngine.IFRDocument.AddImageDocument(Native Method)
I resolved this by creating two distinct ImageDocument objects.
This is not really great as I have to call image preprocessing methods on both objects (crop, enhance local contrast, ....) while they are exactly the same.
Is there a way to reuse ImageDocument objects to avoid this code duplication ?
asked 31 Mar '15, 11:08
Thanks to the code snippet! The reason is that you call
before you finish FRDocument processing. Remove it.
Also, you don't need to call CreateFRDocument and AddImageDocument the second time. The ImageDocument has been already added into the FRDocument, so you just change the profile to TextExtraction_Accuracy and Process the doc again. Please, explore the code snippet below:
answered 01 Apr '15, 20:21
I've just tried to implement the described behavior in Hello sample. It works correctly. Please, see below my code snippet in C#:
Could you please specify the issue in details? What methods do you call? Where does the error message occur (code snippet will be useful)?
answered 31 Mar '15, 17:37
After some testing it seems the problem happens only when loading the image file from memory by using the OpenImageFileFromMemory() method.
The error occurs when calling
Here is the code to reproduce the error (it's in Java) :
Note that for my project I have no choice than loading it from memory.
Ok, I did not know that I could process a document multiple times with different profiles. It solved my problem, thanks :)
answered 02 Apr '15, 14:58