Convert Notepad TXT file to PDF in C#

Notepad provides the easiest and quickest way to write down the important points or create notes. Furthermore, various applications generate useful information in the form of TXT files. Since TXT files do not support advanced features, such as annotations, etc., you may need to convert them to PDF format. To perform this conversion from within .NET applications, this article covers how to convert TXT files to PDF format using C#.

C# Library for TXT to PDF Conversion

In order to convert TXT files to PDF, we will use Aspose.Words for .NET. It is a feature-rich and widely used library to create and manipulate word processing documents. Moreover, it provides a high-quality document converter to convert Word documents and plain text files. You can download the API’s DLL or install it directly from NuGet using the package manager console.

PM> Install-Package Aspose.Words

Convert a TXT File to PDF in C#

The conversion of a TXT file to PDF format using Aspose.Words is extremely straightforward. Just load the TXT file and save it as a PDF document to your desired location. The following are the steps to convert a TXT file to PDF in C#.

The following code sample shows how to convert a TXT file to PDF format.

The following screenshot shows the converted PDF file.

Convert TXT files to PDF programmatically using C#

Converted PDF File

Get a Free API License

You can get a temporary license to use Aspose.Words for .NET without evaluation limitations.


In this article, you have learned how to convert TXT files to PDF format in C#. You can simply install Aspose.Words for .NET and automate TXT to PDF conversion in your applications. Besides, you can explore more about Aspose.Words for .NET using the documentation. Also, you can post your queries or questions to our forum.

See Also