I use the https://github.com/codaxy/wkhtmltopdf shell to create a pdf file from a web page on my website (I go to the absolute URL, for example http://mywebsite.azurewebsites.net/PageToRender.aspx He works fine in dev and on another shared hosting account, but when I deploy to the Azure site, it fails, and all I get is a ThreadAbortException exception, Can wkhtmltopdf be used on azure, and if so, what am I doing wrong?
UPDATE: This simple example using Process.Start also does not work. It just freezes when Azure starts up, but works fine on other servers.
string exePath = System.Web.HttpContext.Current.Server.MapPath("\\App_Data\\PdfGenerator\\wkhtmltopdf.exe"); string htmlPath = System.Web.HttpContext.Current.Server.MapPath("\\App_Data\\PdfGenerator\\Test.html"); string pdfPath = System.Web.HttpContext.Current.Server.MapPath("\\App_Data\\PdfGenerator\\Test.pdf"); StringBuilder error = new StringBuilder(); using (var process = new Process()) { using (Stream fs = new FileStream(pdfPath, FileMode.Create)) { process.StartInfo.FileName = exePath; process.StartInfo.Arguments = string.Format("{0} -", htmlPath); process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; process.StartInfo.UseShellExecute = false; process.Start(); while (!process.HasExited) { process.StandardOutput.BaseStream.CopyTo(fs); } process.WaitForExit(); } }
source share