string url = HttpContext.Current.Server.MapPath("HTMLPage.htm"); //this will be the output path of pfd file string filepath = HttpContext.Current.Server.MapPath("PDF/saif.pdf"); //variable to store pdf file content byte[] fileContent = null; System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.UseShellExecute = false; process.StartInfo.CreateNoWindow = true; //set the executable location process.StartInfo.FileName = HttpContext.Current.Server.MapPath("PDFConverter/wkhtmltopdf.exe"); //set the arguments to the exectuable // wkhtmltopdf [OPTIONS]... <input fileContent> [More input fileContents] <output filecontent=""> process.StartInfo.Arguments = url + " " + filepath; // process.StartInfo.Arguments = "this is the test"+""+filepath; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; process.StartInfo.RedirectStandardInput = true; //run the executable process.Start(); //wait until the conversion is done process.WaitForExit(); // read the exit code, close process int returnCode = process.ExitCode; process.Close(); //initialize the filestream with filepath FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.Read); fileContent = new byte[(int)fs.Length]; //read the content fs.Read(fileContent, 0, (int)fs.Length); //close the stream fs.Close(); return fileContent;
htmlpage.html
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)