How to highlight a text by using Essential PDF?
To highlight a text in the PDF document using .NET Excel library , PdfTextMarkupAnnotation and select PdfMarkupAnnotationType as the highlight. You 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.
C#
//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. page.Annotations.Add(textannot); //Saves the document. doc.Save("highlight.pdf"); //Closes the document. doc.Close(true);
Sample Link:
Conclusion
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 forums, Direct-Trac, or feedbackportal. We are always happy to assist you!