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. Image for the cookie policy date

Yellow highlighting in PDF

Dear Syncfusion,
is it possible to make a yellow highligthing like shown in example? I have just blank PDF and I want to highlight some specific text or paragraph.

Thank you for your help.

Best regards,
Jan Bednar

Attachment: cut_cdc0ad45.zip

3 Replies

PH Praveenkumar H Syncfusion Team December 16, 2016 11:51 AM UTC

Hi Jan, 
Thank you for using Syncfusion products. 
You can highlight the particular text or paragraph by using PdfTextMarkupAnnotation with text bounds.  
Please find the code snippet to highlight the particular text, 
RectangleF rect = new RectangleF(55, 100, 280, 20); 
PdfTextMarkupAnnotation textannot = new PdfTextMarkupAnnotation(rect); 
textannot.TextMarkupAnnotationType = PdfTextMarkupAnnotationType.Highlight; 
textannot.TextMarkupColor = new PdfColor(Color.Yellow); 
page.Annotations.Add(textannot); 
 
Please let us know if you have any concerns. 
With Regards, 
Praveen 



JB Jan Bednar December 16, 2016 02:29 PM UTC

Dear Syncfusion,
thank you for your update. Is it possible to extract the text from PDF and then highlight the chosen one?

Thank you,
Jan Bednar


GR Gayathri Ramalingam Syncfusion Team December 19, 2016 11:35 AM UTC

Hi Jan, 
Thank you for your update. 
You can extract the text from PdfLoadedDocument by using ExtractText().  
Please find the code snippet to Extract the text form Loaded document, 
PdfLoadedDocument lDoc = new PdfLoadedDocument(@"Input.pdf");            
PdfLoadedPage page = lDoc.Pages[0] as PdfLoadedPage; 
string text= page.ExtractText(); 
 
And you can highlight the chosen text or paragraph by using PdfTextMarkupAnnotation with text bounds.  
You can get the bounds value of the selected text by using below code, 
lDoc.FindText(text, out rectCollection); 
 
We have created a sample to highlight the text in Windows Forms. Please find the sample from the below link, 
Sample link: 
 
Please let us know if you have any concerns. 
 
With Regards, 
Gayathri R 
 
 


Loader.
Up arrow icon