代码之家  ›  专栏  ›  技术社区  ›  Syl20

rotativa-wkhtmltopdf已停止工作

  •  0
  • Syl20  · 技术社区  · 8 年前

    在ASP.NET MVC应用程序中,当尝试使用Rotativa生成某些PDF时,我得到以下异常(没有实际的消息,只是一个堆栈跟踪)。

    rotativa.wkhtmltopdfdriver.convert处出现System.Exception(字符串 wkhtmltopdfpath,字符串开关,字符串html)at rotativa.wkhtmltopdfdriver.converthtml(字符串wkhtmltopdfpath,字符串 开关,字符串html)at rotativa.viewAspdf.callTheDriver(ControllerContext上下文)位于 rotativa.aspdfresultbase.buildpdf(ControllerContext上下文)位于 rotativa.aspdfresultbase.executeResult(ControllerContext上下文)
    在 System.Web.MVC.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext,actionResult actionResult)位于 System.Web.MVC.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList 1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList 一 筛选器,Int32 FilterIndex,ResultExecuting上下文预上下文, controllerContext controllerContext,actionResult actionResult)位于 System.Web.MVC.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList 1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList 1个过滤器,actionResult actionResult)位于 system.web.mvc.async.asyncControllerActionInvoker.<>c_uu DisplayClass21.<>c_uu DisplayClass2b.b_uuuu1c()) 在 System.Web.MVC.Async.AsyncControllerActionInvoker.<>C_uuDisplayClass21.B_uu1e(IAsyncResult 异步结果) system.web.mvc.async.asyncResultWrapper.wrappedAsyncResult 1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase 1)() 在 system.web.mvc.async.asyncControllerActionInvoker.endinvokeAction(IAsyncResult 异步结果) system.web.mvc.controller.b_uu1d(iasyncresult asyncResult,executeCrepreset innerState)位于 system.web.mvc.async.asyncResultWrapper.wrappedAsyncvoid 1.被叫方委托(IAsyncResult 异步结果) system.web.mvc.async.asyncResultWrapper.wrappedAsyncResultBase 1)() 在System.Web.MVC.Controller.EndExecuteCore(IAsyncResult AsyncResult)上 在system.web.mvc.controller.b_uuu 15(iasyncresult AsyncResult,控制器控制器)位于 system.web.mvc.async.asyncResultWrapper.wrappedAsyncvoid 1.被叫方委托(IAsyncResult 异步结果) system.web.mvc.async.asyncResultWrapper.wrappedAsyncResultBase 1)() at system.web.mvc.controller.endExecute(IAsyncResult异步结果)
    在 System.Web.MVC.Controller.System.Web.MVC.Async.IAsyncController.EndExecute(IAsyncResult 异步结果) system.web.mvc.mvchandler.b_uuu 5(iasyncresult asyncResult,processRequestState innerState)位于 system.web.mvc.async.asyncResultWrapper.wrappedAsyncvoid 1.被叫方委托(IAsyncResult 异步结果) system.web.mvc.async.asyncResultWrapper.wrappedAsyncResultBase 1)() at system.web.mvc.mvchandler.endprocessrequest(iasyncresult 异步结果) system.web.mvc.mvchandler.system.web.ihtpasynchandler.endprocessrequest(iasyncresult 结果) system.web.httpapplication.callHandlerExecutionStep.system.web.httpapplication.ieExecutionStep.execute()) 在system.web.httpapplication.executestepimpl(iexecutionstep步骤)
    在system.web.httpapplication.executestep(iexecutionstep步骤, 布尔值(同步完成)

    该问题与VisualStudio 2013(MSVCP120 .DLL)中缺少的C++可重分配包无关,因为它们安装在机器上。 实际上,一些PDF可以通过应用程序生成,这让我觉得视图中有些东西导致WKHTMLTOPDF有时停止工作…

    知道是什么导致了这个异常或者我如何调试它吗?

    (Rotativa版本为1.6.4,我使用的是MVC5)

    1 回复  |  直到 8 年前
        1
  •  0
  •   Syl20    8 年前

    经过多次尝试和错误,我找到了解决方案。这个 question 也为我指明了正确的方向。这显然是WKHTMLTOPDF分页算法和大型表或HTML块的问题。所以,为了解决我的问题,我把HTML改成了更小的块,现在它可以工作了。

    推荐文章