複数のURLを渡してwkhtmltopdfを使用してASP.Netアプリケーションで複数ページのPDFドキュメントを生成しようとしています。wkhtmltopdf複数ページのPDF生成プロセスがハングアップする
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
今私が午前問題は、それが次のエラーメッセージと
p.WaitForExit(60000)
でのエラーである - ここで
が呼び出されるコードです。
Process must exit before requested information can be determined.
しかし、このエラーが唯一の私は以上4つのまたは5のURLを渡すときに発生するようで、それはその時々より、その少ない時々、ランダムなようです。これにより、プロセスがPDFを生成するのに長い時間がかかるため、p.WaitForExitでエラーが発生します。
リクエストの制限があるのでしょうか?私は、コマンドプロンプトを直接使用するときに必要な数のURLでPDFを生成できます。