Free Support Forum -

Possibility of highlighting text in pdf by c#


Please can you give code for the dynamically highlight the text in pdf by Aspose.pdf . please check the required output as i want with attached pdf .

can it is possible for whole pdf .

please update me ASAP.

laxman singh

Hi Laxman,

Thanks for contacting support.

In order to accomplish your requirement, please try using CreateMarkup(…) method of PdfContentEditor class. Please take a look over the following code snippet.

For your reference, I have also attached the sample PDF file generated with this code.


PdfContentEditor editor = new


editor.CreateMarkup(new System.Drawing.Rectangle(87,513, 90,10),"", 0, 1, System.Drawing.Color.Yellow);


How can find the coordinates of the word in pdf , i needed sample code for as below condition .

first search the word in whole pdf than highlight the world or text in the pdf ,it can be doable if yes please
provide methe sample code for the same ASAP.

for example:

if “laxman is doog boy” meets 5 times in pdf than application highlight the pdf text five times.

laxman singh

Hi Laxman,

In case you need to search particular string and need to get its coordinates/position information, then I would suggest you to please try using the code snippet shared over Replace Text in All Pages of a PDF Document (instead of replacing the whole string, you can only specify/set the ForgroundColor of TextFragment.

In the event of any further query, please feel free to contact.