There are cases where you need to point out the content that has mistakes or it is no more valid. Crossing out is one of the ways to mark the invalid content within the documents. So, in order to automate the striking out within .NET applications, this article shows how to strikethrough text in documents using C#.
The following topics are discussed in this article.
.NET API to Strikethrough Text
GroupDocs.Annotation is a document and image annotation solution that allows automating various annotation types within multiple document formats. Therefore, I will use its .NET API in the examples of this article to strikethrough text within the documents. In addition to the strikeout annotation, there are many other supported annotation types mentioned in the documentation.
Download the DLLs or MSI installer from the downloads section or install the API in your .NET application via NuGet.
PM> Install-Package GroupDocs.Annotation
How to Strikethrough Text in Documents using C#
Let’s quickly start to strike out the identified mistakes with the document. The following steps allow you to strikethrough the text in documents using C#.
- Load the source document using Annotator class.
- Create and define the strikethrough annotation using StrikeoutAnnotation class.
- Set the strikeout line color.
- Opacity, document page number
- Coordinates and other properties
- Add the prepared strikeout annotation to the annotator using Add() method.
- Save the annotated document using the Save() method.
The following C# code example crosses out the selected text in a PDF document.
Get a Free API License
You can use GroupDocs.Annotation for .NET for free by getting a temporary license.
Conclusion
To sum up, you learned to add strikethrough annotation using C#. Using this annotation, you can programmatically strike out the text within Word, PDF, spreadsheet, presentation documents. Similarly, you can try various other annotation types according to your requirement.
Learn more about GroupDocs.Annotation for .NET by visiting its documentation. You can build your own annotator application for the supported document formats. You can contact us for queries via the forum.