News Category

C#/VB.NET: Convert PDF to HTML

2022-05-24 06:30:00 Written by  support iceblue
Rate this item
(0 votes)

For various reasons, you may want to convert PDF to HTML. For example, you need to share PDF documents on social media or publish PDF content on the web. In this article, you will learn how to convert PDF to HTML in C# and VB.NET using Spire.PDF for .NET.

Install Spire.PDF for .NET

To begin with, you need to add the DLL files included in the Spire.PDF 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.PDF

Convert PDF to HTML in C# and VB.NET

The following are the steps to convert a PDF document to HTML:

  • Initialize an instance of PdfDocument class.
  • Load a PDF document using PdfDocument.LoadFromFile(filePath) method.
  • Save the PDF document as HTML using PdfDocument.SaveToFile(filePath, FileFormat.HTML) method.
  • C#
  • VB.NET
using Spire.Pdf;

namespace ConvertPdfToHtml
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a PdfDocument instance
            PdfDocument pdf = new PdfDocument();
            //Load a PDF document
            pdf.LoadFromFile(@"C:\Users\Administrator\Desktop\Sample.pdf");

            //Save the PDF document as HTML
            pdf.SaveToFile(@"C:\Users\Administrator\Desktop\ToHtml.html", FileFormat.HTML);
        }
    }
}

C#/VB.NET: Convert PDF to HTML

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 Tuesday, 20 June 2023 01:44