In this article I will explain how to convert PDF file to HTML file in ASP.Net using C# and VB.Net. PDF file will be converted to HTML file in ASP.Net using the PdfToHtml.exe file.
 
 
Download PdfToHtml.exe file
You can download PdfToHtml.exe file using the following download link.
 
 
HTML Markup
The HTML Markup consists of an ASP.Net FileUpload control and a Button.
<asp:FileUpload ID="FileUpload1" runat="server" />
<hr />
<asp:Button Text="Upload" runat="server" OnClick="Upload" />
 
 
Namespaces
You will need to import the following namespaces.
C#
using System.IO;
using System.Diagnostics;
 
VB.Net
Imports System.IO
Imports System.Diagnostics
 
 
Uploading and converting PDF file to HTML in ASP.Net
The following event handler is executed when the Upload button is clicked. The uploaded PDF file is saved to the Output folder.
Note: It is very important to remove space characters from the PDF file name as otherwise the HTML file will not be generated.
The path of the input PDF file and the path of the output HTML file are passed as Arguments to the ProcessStartInfo object.
The path of the PdfToHtml.exe file is set to the FileName property of the ProcessStartInfo object.
Finally the PdfToHtml.exe file is executed and the PDF file is converted and saved as HTML file in the Output folder.
C#
protected void Upload(object sender, EventArgs e)
{
    //Get the File Name. Remove space characters from File Name.
    string fileName = FileUpload1.FileName.Replace(" ", string.Empty);
 
    //Save the PDF file.
    string inputPath = Server.MapPath("~/Output/") + Path.GetFileName(fileName);
    FileUpload1.SaveAs(inputPath);
 
    //Set the HTML file path.
    string outputPath = Server.MapPath("~/Output/") + Path.GetFileNameWithoutExtension(fileName) + ".html";
 
    ProcessStartInfo startInfo = new ProcessStartInfo();
 
    //Set the PDF File Path and HTML File Path as arguments.
    startInfo.Arguments = string.Format("{0} {1}", inputPath, outputPath);
 
    //Set the Path of the PdfToHtml exe file.
    startInfo.FileName = Server.MapPath("~/PdfToHtml/pdftohtml.exe");
 
    //Hide the Command window.
    startInfo.WindowStyle = ProcessWindowStyle.Hidden;
    startInfo.CreateNoWindow = true;
 
    //Execute the PdfToHtml exe file.
    using (Process process = Process.Start(startInfo))
    {
        process.WaitForExit();
    }
}
 
VB.Net
Protected Sub Upload(sender As Object, e As EventArgs)
    'Get the File Name. Remove space characters from File Name.
    Dim fileName As String = FileUpload1.FileName.Replace(" ", String.Empty)
 
    'Save the PDF file.
    Dim inputPath As String = Server.MapPath("~/Output/") + Path.GetFileName(fileName)
    FileUpload1.SaveAs(inputPath)
 
    'Set the HTML file path.
    Dim outputPath As String = Server.MapPath("~/Output/") + Path.GetFileNameWithoutExtension(fileName) + ".html"
 
    Dim startInfo As New ProcessStartInfo()
 
    'Set the PDF File Path and HTML File Path as arguments.
    startInfo.Arguments = String.Format("{0} {1}", inputPath, outputPath)
 
    'Set the Path of the PdfToHtml exe file.
    startInfo.FileName = Server.MapPath("~/PdfToHtml/pdftohtml.exe")
 
    'Hide the Command window.
    startInfo.WindowStyle = ProcessWindowStyle.Hidden
    startInfo.CreateNoWindow = True
 
    'Execute the PdfToHtml exe file.
    Using process As Process = process.Start(startInfo)
        process.WaitForExit()
    End Using
End Sub
 
 
Screenshots
The PDF file
Convert PDF file to HTML in ASP.Net using C# and VB.Net
 
The converted HTML file
Convert PDF file to HTML in ASP.Net using C# and VB.Net
 
 
Downloads