Articles in this section
Category / Section

How to highlight a text by using Essential PDF?

1 min read

To highlight a text ithe PDF document using .NET Excel library , PdfTextMarkupAnnotation and select PdfMarkupAnnotationType as the highlightYou can also change the highlight color by using the TextMarkupColor property. The following code example shows how to highlight a text by using Essential PDF.


            //Creates a new Pdfdocument.
            PdfDocument doc = new PdfDocument();
            //Adds a new Page.
            PdfPage page = doc.Pages.Add();
            //Creates a solid brush.
            PdfBrush brush = new PdfSolidBrush(System.Drawing.Color.Black);
            //Sets the font.
            PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20);
            //Draws the text.
            page.Graphics.DrawString("This is Highlighted text", font, brush, new PointF(100, 50));
            //Creates a PDF text Markup annotation.
            PdfTextMarkupAnnotation textannot = new PdfTextMarkupAnnotation("Highlighted             Text", "Highlight", "This is Highlighted text", new PointF(140, 90), font);
            //Sets the Markup type as Highlight.
            textannot.TextMarkupAnnotationType = PdfTextMarkupAnnotationType.Highlight;
            //Sets the HighLight color.
            textannot.TextMarkupColor = new PdfColor(Color.Yellow);
            //Loads the annotation to page.
            //Saves the document.
            //Closes the document.


Sample Link:


I hope you enjoyed learning about how to highlight a text by using how to highlight a text by using Essential PDF.

You can refer to our .NET Excel library page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our .NET Excel library example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or  feedbackportal. We are always happy to assist you!

Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied