0

I created a form in asp.net with following controls.File upload,search textbox and search button.

After browse the pdf file to upload.I'll enter some text "Content" in the text box and click on the button means the pdf file should be open in the web page along with the text entered in textbox(Content) to be highlight in yellow color background.

user2089987
  • 1,041
  • 4
  • 15
  • 23
  • 1
    Did you check out this question?http://stackoverflow.com/questions/8582706/highlighting-text-colors-of-existing-pdf-using-itextsharp-using-c-sharp – Storm Feb 20 '13 at 06:50

1 Answers1

0

To highlight a text in Pdf - Use the below code

protected void Button1_Click(object sender, EventArgs e)
{
   PdfReader read = new PdfReader("C:\\Test.pdf");
   Chunk chk = new Chunk("TextBox1.Text", new Font(Font.TIMES_ROMAN, 14, Font.ITALIC));
   chk.SetBackground(new Color(0xFF, 0x00, 0x00), 10, -50, 20, -10);
}
Princee Singhal
  • 29
  • 1
  • 1
  • 6
  • when i tried to implement this code i am getting error in this line. chk.SetBackground(new Color(0xFF, 0x00, 0x00), 10, -50, 20, -10); What namespace i need to add to overcome this error.I used the itextsharp dll in my code. – user2089987 Feb 22 '13 at 07:29
  • when i tried to implement this code i am getting the error(the type or namespace name color could not be found) in the following line. chk.SetBackground(new Color(0xFF, 0x00, 0x00), 10, -50, 20, -10); What namespace i need to add to overcome this error.I used the itextsharp dll in my code. – user2089987 Feb 22 '13 at 08:39
  • Use this namespace "iTextSharp.Text". – Princee Singhal Feb 23 '13 at 08:50
  • Even after used this namespace the property color and setBackground is not supporting. – user2089987 Feb 23 '13 at 11:59