using PdfTextFragment.HighLight()
the highlighted area is not "transparently", the text it is completely covered.
- Code: Select all
private void button2_Click(object sender, EventArgs e)
{
PdfDocument pdfDoc = new PdfDocument(@"d:\tmp\test2.pdf");
foreach (PdfPageBase page in pdfDoc.Pages)
{
PdfTextFinder finder = new PdfTextFinder(page);
//finder.Options.Parameter = TextFindParameter.WholeWord;
finder.Options.Parameter = TextFindParameter.IgnoreCase;
List<PdfTextFragment> finds = finder.Find(this.textBox1.Text);
foreach (PdfTextFragment fragment in finds)
{
// Highlight text
fragment.HighLight(Color.LightYellow);
}
}
this.pdfDocumentViewer1.LoadFromStream(pdfDoc.SaveToStream(FileFormat.PDF)[0]);
}
regards peter