You must Sign In to post a response.
  • Category: ASP.NET

    How to highlight a selected text on pdf using & C#?

    In my application has lot of pdfs. if i have searched a text then the matched pdf file name should display with link to that pdf first matched page. if click on the link it opens the pdf page with highlight the searched text.

    How to highlight (background color change) a selected text on a PDF file using with C# code? if u have any idea share with me plz. since two days i am struggle with this.
  • #743763
    For searching a pdf file in a directory below link will help you,

    For searching a string inside a pdf file browse below links,

    Vignesh Kannan

  • #743801

    Are you using any third party tools for showing the PDF files/For searching?

    Highlighting text of existing PDF can be done using iTextsharp in C#

    you can refer to this example exactly giving the code what you are looking for but this is using iTextSharp

  • #765771
    download c# pdf highlight existing fields and try this high quality software on rasteredge, get the free trail and vip service on page

  • #765796
    You can go through blow link:
    Download the free version from codeplex and give it a try:
    Sample code:

    PdfDocument pdf = new PdfDocument(@"E:\···\PDF.pdf");
    PdfTextFind[] result = null;
    foreach (PdfPageBase page in pdf.Pages)
    result = page.FindText("text").Finds;
    foreach (PdfTextFind find in result)

  • #765802
    So you have couple of task
    1. search a word in pdf
    2. Highlight that word in pdf file
    There is not API exist in .net to support PDF files, To accomplish first task you need to take support of some third party API like PDF sharp/ItextSharp
    here is the sample that will works for you

    using iTextSharp.text.pdf;
    using iTextSharp.text.pdf.parser;
    // ...
    public static string ExtractTextFromPdf(string path)
    using (PdfReader reader = new PdfReader(path))
    StringBuilder text = new StringBuilder();
    for (int i = 1; i <= reader.NumberOfPages; i++)
    text.Append(PdfTextExtractor.GetTextFromPage(reader, i));
    return text.ToString();

    You need to import iTextsharp dll for it, may be following link will help you more

    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #766014
    You can implement this using itextsharp as shown below:
    Also, I saw a similar feature implemented by leadtools in the following thread:

  • Sign In to post your comments