Convert PDF file to HTML in Console Application using C#

Last Reply one month ago By dharmendr

Posted one month ago

Hi with reference to the below link:

Convert PDF file to HTML in ASP.Net using C# and VB.Net

I tried the code below but I am not able to get any result to the HTML file from PDF. 

    public class pdf2html
    {
        public static void Getdata()
        {
            string inputPath = "mytestpdf.pdf";
            string outputPath = "pdftest.html";
            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.Arguments = string.Format("{0} {1}", inputPath, outputPath);

            startInfo.FileName = "pdftohtml.exe";

            startInfo.WindowStyle = ProcessWindowStyle.Hidden;
            startInfo.CreateNoWindow = true;

            //Execute the PdfToHtml exe file.
            using (Process process = Process.Start(startInfo))
            {
                process.WaitForExit();
            }
        }
    }

 

You are viewing reply posted by: dharmendr one month ago.
Posted one month ago

Hi Vikash21,

1. Please pass proper inputPath and output pathof the file.

2. Remove space from the file name.

3. pass proper path of the exe file.

C#

class Program
{
    static void Main(string[] args)
    {
        string inputPath = @"C:\Users\Test\Desktop\PdfToHtml\MudassarKhan.pdf";
        string outputPath = @"C:\Users\Test\Desktop\PdfToHtml\MudassarKhan.html";
        ProcessStartInfo startInfo = new ProcessStartInfo();
        startInfo.Arguments = string.Format("{0} {1}", inputPath, outputPath);
        startInfo.FileName = @"C:\Users\Test\Desktop\PdfToHtml\pdftohtml.exe";
        startInfo.WindowStyle = ProcessWindowStyle.Hidden;
        startInfo.CreateNoWindow = true;
        using (Process process = Process.Start(startInfo))
        {
            process.WaitForExit();
        }
    }
}