Possibility of highlighting text in pdf by c#

Hello,


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.

thanks,
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.

[C#]

PdfContentEditor editor = new
PdfContentEditor();<o:p></o:p>

editor.BindPdf("c:/pdftest/A5SizePDF2.pdf");

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

editor.Save("c:/pdftest/HighLighted_Text_example_out.pdf");

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.

thanks,
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.