Click here to Skip to main content
11,637,415 members (57,312 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Visual-Studio
Hi,

I am using below code to exract text from pdf file,
public string ReadPdfFile()
{
    string strText = string.Empty;
    try
    {
        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;
 
        }
        reader.Close();
    }
    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?

Regards,
Kane
Posted 28-Feb-13 2:37am
Edited 28-Feb-13 2:45am
v2

1 solution

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

Solution 1

  Permalink  
Comments
Vandana87 at 4-Jun-15 2:32am
   
HI,
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.

Thankyou.

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

  Print Answers RSS
0 OriginalGriff 295
1 stibee 288
2 jyo.net 270
3 Sergey Alexandrovich Kryukov 224
4 himanshu agarwal 184
0 OriginalGriff 9,031
1 Sergey Alexandrovich Kryukov 8,643
2 Mika Wendelius 6,959
3 F-ES Sitecore 2,388
4 Suvendu Shekhar Giri 2,320


Advertise | Privacy | Mobile
Web03 | 2.8.150728.1 | Last Updated 28 Feb 2013
Copyright © CodeProject, 1999-2015
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