We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Draw Rectangle Behind Text

Thread ID:





115866 Feb 15,2014 12:02 AM UTC Feb 20,2014 07:07 AM UTC WPF 1
Tags: PdfViewer
Chuck Berg
Asked On February 15, 2014 12:02 AM UTC

The following code draws a rectangle around the searched-for text.  But if I choose PdfBrushes.Red for the fill, it covers up the text completely. How do I modify this code such that the rectangle is behind the text instead of in front of it?

Dictionary<int, List<RectangleF>> matchText = null;
pdfViewerControl1.FindText(searchText, out matchText);

foreach (int page in matchText.Keys)
   foreach (RectangleF rect in matchText[page])
       PdfGraphics graphics = doc.Pages[page].Graphics;
       graphics.DrawRectangle(PdfPens.Red, PdfBrushes.Transparent, rect);

Thanks for any help.

Meikanda Nayanar [Syncfusion]
Replied On February 20, 2014 07:07 AM UTC

Hi Chuck,

We have analyzed your requirement and found that we cannot fill the rectangle behind the text, but we can achieve this by setting the transparency of the graphics as in the below snippet.


graphics.DrawRectangle(PdfBrushes.Red, rect);


We have attached a simple sample on this for your reference below.

Please let us know if you need any further assistance.



Attachment: Sample_4c593e12.zip


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon