I have tried this
string text = "";
using (PdfReader pdfReader = new PdfReader(dlg.FileName))
{
for (int page = 1; page <= pdfReader.NumberOfPages; page++)
{
text = PdfTextExtractor.GetTextFromPage(pdfReader, page);
}
}
text = text.Replace("\n", "\r\n");
which gave me this result
"AI(240)10575323190069
AI(13)240215
24-02-15 (YY-MM-DD)
PI-734875-1
19006
© Inter IKEA Systems
B.V. 2021
105.753.23
Made in Pakistan"
it just misses "2407"
that is written in most right side of the PDF, as seen below. Is there a way that I can read that from my PDF?
I am expecting to read rotated text on the right side of the document along with all.
This is the content of my PDF file:
I have tried this
string text = "";
using (PdfReader pdfReader = new PdfReader(dlg.FileName))
{
for (int page = 1; page <= pdfReader.NumberOfPages; page++)
{
text = PdfTextExtractor.GetTextFromPage(pdfReader, page);
}
}
text = text.Replace("\n", "\r\n");
which gave me this result
"AI(240)10575323190069
AI(13)240215
24-02-15 (YY-MM-DD)
PI-734875-1
19006
© Inter IKEA Systems
B.V. 2021
105.753.23
Made in Pakistan"
it just misses "2407"
that is written in most right side of the PDF, as seen below. Is there a way that I can read that from my PDF?
I am expecting to read rotated text on the right side of the document along with all.
This is the content of my PDF file:
OCR is often problematic especially for numbers so if you have 95 % correct it is good and then you only need to correct or add the last 5%.
Avoid OCR for numbers as often they will be missing or incorrect, and the large 105.753.23
is often not recognised in a page of other text.
Here I used the online Demo of SautinSoft and can get that 2407 but for every other image it may not be the case. OCR is never "Guaranteed" nor should be.
You can get the same (or better quality) simply by asking tesseract to generate both text and PDF at the same time like here.
Note again that both the 105.753.23
and 19006
have been misread as MAA ATT.
M
a
d
e
` `i
n
etc were next to each other (in the file, not the printed page) and so were treated as consecutive text. Libraries have to guess whether the positioning and rendering instructions they find are text or not. – Panagiotis Kanavos Commented Jan 30 at 9:2819006
and105.754.23
weren't extracted either. It may not be possible to extract them (or the "rotated" text) or you may have to use a different TextExtractionStrategy – Panagiotis Kanavos Commented Jan 30 at 9:35but an image.
you can't read it as text then. You'll have to use an OCR library. Which, by the way, is quite often the best option with PDFs. iText does that with its pdfOCR product, which uses the Tesseract library underneath. – Panagiotis Kanavos Commented Jan 30 at 9:38