Convert PDF file to HTML in Console Application using C#

Last Reply 3 months ago By dharmendr

Posted 3 months 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 3 months ago.
Posted 3 months 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();
        }
    }
}