Click here to Skip to main content
15,900,815 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:

I am using below code to exract text from pdf file,
public string ReadPdfFile()
    string strText = string.Empty;
        PdfReader reader = new PdfReader(@"\\FilePath");
        for (int page = 1; page <= reader.NumberOfPages; page++)
            ITextExtractionStrategy its = new iTextSharp.text.pdf.parser.SimpleTextExtractionStrategy();
            String s = PdfTextExtractor.GetTextFromPage(reader, page, its);
            s = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(s)));
            strText = strText + s;
    catch (Exception ex)
    return strText;

This code returns all the text from one page of the PDF file, I need to highlight any word of my choice on that PDF page with yellow colour.

Any ideas how to do that?

Updated 20-Jun-16 0:25am

1 solution

Share this answer
Vandana87 4-Jun-15 2:32am    
can you please tel me where you are providing the text(Text or Word that you want to find in the PDF). strText is empty and s gives you entire pdf content. Please tel me if you i want to find a word in the pdf hw can i do it. i have values like page number , word number and total number of words to b highlighted.

Please guide me for the same.


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