ExtractText method throws Indexoutofrange exception when using out TextLineCollection parameter
Dear Team,
In Winforms application, when attempting to extract text from a PDF file into Textlines, the below exception is thrown:
System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index'
Sample code:
//Load first page
PdfPageBase page = loadedDocument.Pages[0];
TextLines tlines= new TextLines();
//Extract text from first page
page.ExtractText(out tlines); //Exception in this line
//Close the document
loadedDocument.Close(true);
Similar bug raised for Textdata collection:
[Bug] System.IndexOutOfRangeException when ExtractText | WinForms Forums | Syncfusion
Thanks
Santhosh
Hi Santhosh,
We have tried to reproduce the reported behavior with the provided details on our end but we were unable to reproduce the reported issue with the pdf in the [Bug] System.IndexOutOfRangeException when ExtractText | WinForms Forums | Syncfusion. We have attached the sample for your reference. Please try this on your end and let us know the result.
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/NetFramework-511199399
If you are still facing issue with the other document. Please share with us the modified sample with us. So that we can assist with you further in this.
Regards,
Irfana J.
Dear Irfana,
Please try with the attached file. This file throws an error.
Also, I need some help with performing OCR on a JPEG file. The OCRed text is garbled/corrupted. When I convert the image as PDF, the resultant searchable PDF looks fine. But reading from the searchable pdf or the OCRed text from the image are not readable.
Please provide me a sample of the OCR code in Winforms.
Thanks
Santhosh
Hi Santhosh Kumar,
Currently, we are creating a sample to perform OCR on Image without OCRed text corrupted in Winforms. We will update further details on November 19th, 2024.
Regards,
Arumugam M
Hi Santhosh Kumar,
Upon further analysis, we have created sample Winforms application to perform OCR with the provided image. The resultant OCRed text was accurate as expected and not corrupted. We have attached the sample and output document below for your reference
Sample: Perform-OCR207739126
Output: OCR_Result-216355667
Please try the above sample and let us know the result. Kindly get back to us if you need any further assistance in this.
Regards,
Arumugam M
Dear Arumugam,
The sample also works for some files and not others.
The PDF file throws an error if I try to extract the files into textlines (the original question raised here). I'm able to extract text into a string, list<textdata> etc. though.
The JPEG file when I perform OCR and save it as a searchable pdf, the resultant pdf works. but when i extract the data from the pdf document, the text is not what as per text in the image.
I have attached two sample files one pdf and a JPEG file for your analysis. Two screenshots are also attached one of an exception while performing OCR and another the improper text read from the image file when extracting from the resultant searchable PDF.
I'm trying to import the data in the image and pdfs into SQL server database. I understand the files could be problematic, but we currently have a third-party application where these two files are read properly, and the data is imported properly. We want to move to an in-house developed solution for this and are evaluating the Syncfusion PDF and OCR components for this.
Is there any way to identify such files and read them correctly from some properties. What adjustments need to be done in the code to achieve the desired result?
Thanks
Santhosh
Attachment: Sample_files_bbb5f41f.zip
Hi Santhosh,
We have checked the reported issue on our end. Upon further analysis, you have issue with text extraction in PDF document it seems. We were able to reproduce the reported issue regarding text extraction. Currently, we are validating this and we will update further details on November 25th, 2024.
Kindly get back to us, If you have any queries regarding OCR.
Regards,
Arumugam M
Hi Santhosh,
We have confirmed the issue “ExtractText method throws Indexoutofrange exception while using TextLinecollection API” as a defect in our product and we will include the fix in weekly release on 17th December 2024
Please use the below feedback link to track the status of the reported bug.
Note: If you require a patch for the reported issue in any of our Essential Studio Main or SP release version, then kindly let us know the version, so that we can provide a patch in that version based on our SLA policy.
Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.”
Regards,
Raashith Ahamed
Hi Santhosh,
The weekly release will be postponed to tomorrow, December 18, 2024. We kindly ask for your patience and understanding in the meantime.
Regards,
Irfana J.
Hi Santhosh,
Thank you so much!
- 11 Replies
- 4 Participants
-
SK Santhosh Kumar
- Nov 13, 2024 06:17 AM UTC
- Dec 19, 2024 08:46 AM UTC