Last active
August 5, 2022 17:48
-
-
Save groupdocs-com-kb/38da229b4e9becd8d32a09dcb720e0bc to your computer and use it in GitHub Desktop.
How to Convert HTML to Text in C#. For more information, please follow link: https://kb.groupdocs.com/conversion/net/how-to-convert-html-to-text-in-csharp/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using GroupDocs.Conversion.Options.Convert; | |
namespace ConvertHtmlToTextInCSharp | |
{ | |
class Program | |
{ | |
public static void Main(string[] args) // Main function to convert HTML to Text using C# | |
{ | |
// Remove the watermark in output Text document by adding license | |
string licensePath = "GroupDocs.Conversion.lic"; | |
GroupDocs.Conversion.License lic = new GroupDocs.Conversion.License(); | |
lic.SetLicense(licensePath); | |
// Load the source HTML file for conversion to TXT | |
var converter = new GroupDocs.Conversion.Converter("sample.html"); | |
// Set the convert options for TXT file | |
WordProcessingConvertOptions convertOptions = new WordProcessingConvertOptions { | |
Format = GroupDocs.Conversion.FileTypes.WordProcessingFileType.Txt | |
}; | |
// Convert and save the HTML in TXT format | |
converter.Convert("converted.txt", convertOptions); | |
Console.WriteLine("Done"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment