none
Can't run wkhtmltopdf in Azure website RRS feed

  • Question

  • I'm using wkhtmltopdf to create a pdf from a web page on my websit. I want to move to azure but can't get it to run on azure. It just hangs for ages until the request timesout.

    I pass in an html file. It works fine in dev and on another shared hosting account but when I deploy to an Azure website it fails. Is it possible to use wkhtmltopdf on azure, and if so, what am I doing wrong?

    Here is some simple example code that doesn't work.

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

    Thursday, January 24, 2013 5:03 PM

Answers

All replies