mvc, pdf

itextsharp/c#

do you know how to get text's location just like (x, y coordinate)? for example, i have pdf with 2 pages and I want to look for text called 'esign'
if the esign is found, i want to drop the image just next to esign on the right.
LVL 1
ITsolutionWizardAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ITsolutionWizardAuthor Commented:
Help?
0
MishaProgrammerCommented:
Read this post for solve your problem:
https://stackoverflow.com/questions/23909893/getting-coordinates-of-string-using-itextextractionstrategy-and-locationtextextr
Use class Rectangle to get location:
var rect = new iTextSharp.text.Rectangle(
                                                bottomLeft[Vector.I1],
                                                bottomLeft[Vector.I2],
                                                topRight[Vector.I1],
                                                topRight[Vector.I2]
                                                );

Open in new window

0
ITsolutionWizardAuthor Commented:
Sorry I don't get it....I want to search based on the keyword
0
MishaProgrammerCommented:
If you want to find text in PDF file using iTextSharp, you can try to use this code:
                    PdfReader pdfReader = new PdfReader("YourFileName");
                    for (int page = 1; page <= pdfReader.NumberOfPages; page++)
                    {
                        ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();

                        string currentPageText = PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy);
                        if (currentPageText.Contains("YoursearchText"))
                        {
                           //
                        }
                    }
                    pdfReader.Close();
                }

Open in new window

This code was in answer, which I posted later.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET MVC

From novice to tech pro — start learning today.