C#/VB.NET: Convert ODT to PDF

2022-09-20 01:05:19 Written by  support iceblue
Rate this item
(7 votes)

ODT files are OpenDocument Text files created with word processing programs such as free OpenOffice Writer. Like DOCX files, ODT files can contain content like text, images, objects and styles, but they may not be readable by some people who don't have the appropriate application installed. If you plan to share an ODT file, it's best to convert it to pdf so everyone can access it. In this article, we will explain how to convert ODT to PDF in C# and VB.NET using Spire.Doc for .NET.

Install Spire.Doc for .NET

To begin with, you need to add the DLL files included in the Spire.Doc for .NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.

PM> Install-Package Spire.Doc

Convert ODT to PDF using C# and VB.NET

The following are the steps to convert an ODT file to PDF:

  • Create an instance of Document class.
  • Load an ODT file using Document.LoadFromFile() method.
  • Convert the ODT file to PDF using Document.SaveToFile(string fileName, FileFormat fileFormat) method.
  • C#
  • VB.NET
using Spire.Doc;

namespace ConvertOdtToPdf
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //Create a Document instance
            Document doc = new Document();
            //Load an ODT file
            doc.LoadFromFile("Sample.odt");

            //Save the ODT file to PDF
            doc.SaveToFile("OdtToPDF.pdf", FileFormat.PDF);
        }
    }
}

C#/VB.NET: Convert ODT to PDF

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.

Additional Info

  • tutorial_title:
Last modified on Wednesday, 31 May 2023 08:53