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();
            }
        }
    }

 

Posted one month ago
Hi @Vikash21,
Please try the following

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

It might help you.

Cheers Andrea.

Posted one month ago

Hey Vikash21,

I checked article sample, that's working please download article and check with the sample.


Posted one month ago

Hi pandeyism,

I had downloaded the article and then tried with Console application and the same sample pdf as well,  but it doesn't load the result to html file. Is there any line I am missing in the code?


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();
        }
    }
}