Do you need to generate PDF files from the plain text? If yes, this article is going to ease your life by providing a high-speed TXT to PDF conversion solution in C#.
Notepad provides the easiest and quickest way to write down 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. So let’s see how to perform TXT to PDF conversion in a few simple steps.
How to Convert TXT to PDF in C#
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. The best this is, you can convert TXT files to PDF for FREE.
PM> Install-Package Aspose.Words
Save a TXT as 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#.
- Load TXT file using Document class.
- Convert TXT file to PDF using Document.Save(string, SaveFormat) method.
The following code sample shows how to save a TXT file as PDF in C#.
The following screenshot shows the converted PDF file.
Free C# TXT to PDF Converter License
You can get an absolutely free temporary license to use TXT to PDF conversion without any limitations.
In this article, you have learned how to convert TXT files to PDF in C#. You can simply install Aspose.Words for .NET and automate TXT to PDF conversion in your .NET 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.