Click here to Skip to main content
12,553,437 members (58,568 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# Visual-Studio

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?

Posted 28-Feb-13 2:37am
Updated 20-Jun-16 0:25am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.161021.1 | Last Updated 20 Jun 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100