Click here to Skip to main content
15,889,391 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a PDF in which i have to read data from specific coordinates. Is their any way to do so, please help me.
Posted
Comments
ZurdoDev 31-Oct-14 8:59am    
I'd suggest looking at something like iTextSharp which is a popular tool people use for pdfs. Not sure if it can do that.
sumanth n 31-Oct-14 9:49am    
ofcourse we use iTextSharp. I found my solution, thanks for your comment
ZurdoDev 31-Oct-14 10:06am    
Glad you found it.

1 solution

private static void ExtractTextFromRegionOfPdf(string sourceFileName)
        {
            using (Stream pdfStream = new FileStream(sourceFileName, FileMode.Open))
            {
                PdfReader pdfReader = new PdfReader(pdfStream);
                System.util.RectangleJ rect = new System.util.RectangleJ(50, 650, 250, 140);
                RenderFilter[] renderFilter = new RenderFilter[1];
                renderFilter[0] = new RegionTextRenderFilter(rect);
                ITextExtractionStrategy textExtractionStrategy = new FilteredTextRenderListener(new LocationTextExtractionStrategy(), renderFilter);
                Console.WriteLine(PdfTextExtractor.GetTextFromPage(pdfReader, 1, textExtractionStrategy));
            }
        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900