I am attempting to generate a multi-page pdf document in my ASP.Net application using wkhtmltopdf by passing in multiple URLs.
Here is the code that gets called -
Public Shared Function WKHtmlToPdf(ByVal url As String, ByVal OutputDir As String, ByVal OutputFileName As String) As Boolean
Dim blnReturn As Boolean = False
Dim wkhtml As String = HttpContext.Current.Server.MapPath("~/resources/wkhtmltopdf/wkhtmltopdf.exe")
Dim p As New Process()
p.StartInfo.CreateNoWindow = True
p.StartInfo.RedirectStandardOutput = True
p.StartInfo.RedirectStandardError = True
p.StartInfo.RedirectStandardInput = True
p.StartInfo.UseShellExecute = False
p.StartInfo.FileName = wkhtml
p.StartInfo.WorkingDirectory = OutputDir
p.StartInfo.Arguments = url & " " & OutputFileName
p.Start()
p.WaitForExit(60000)
Dim returnCode As Integer = p.ExitCode
p.Close()
If returnCode = 0 Then
blnReturn = True
End If
Return blnReturn
End Function
Now the problem I am having is it errors at
p.WaitForExit(60000)
with the following error message.
Process must exit before requested information can be determined.
However, this error only seems to occur when I pass in more than 4 or 5 URLs, it seems random, sometimes its less, sometimes its more. This causes the process to take a long time to generate the PDF and thus error at p.WaitForExit...
I wondered if there some kind of Request limit being hit? I can generate the PDF with as many URLs I need when using the command prompt directly.