PdfHelper返回对象引用未设置为Umbraco 7.4上的实例



我已经在Umbraco 7.4上安装了PDF Creator。如果我使用Razor Example模板进行测试,我可以创建PDF,但当使用PdfHelper时,它会返回

System.NullReferenceException: Object reference not set to an instance of an object.
Line 3:  @helper Start() {
Line 4:      <!-- Start Root -->
Line 5:         @Html.Raw("<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:ibex="http://www.xmlpdf.com/2003/ibex/Format">")
Line 6:      <!-- End Root -->
Line 7:  }

我创建了一个新模板:

<?xml version="1.0" encoding="UTF-8" ?>
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
    Layout = null;
    //Response.ContentType = "text/xsl";
    //Response.AppendHeader("X-Pdf-Render", "true");
    // -- Uncomment this to force the browser to download the PDF.
    // Response.AppendHeader("X-Pdf-Force-Download","darren.pdf");
}
  @PdfHelper.Start()
    @PdfHelper.MetaData(@CurrentPage.Name, "Darren Ferguson")
    @PdfHelper.LayoutTwoColumnA4()
     @* For ecnryption and password protection there is a:
       PdfHelper.Secure() and PdfHelper.Secure("userPass", "ownerPass") helper *@
    @PdfHelper.StartBody()
       @PdfHelper.StartArea("header")
          @PdfHelper.Block(@CurrentPage.Name, "Arial", "23pt", "#3399ff")
       @PdfHelper.EndArea()
       @PdfHelper.StartArea("body")
          @Pdf.RenderRichText(@CurrentPage.BodyText)
          @PdfHelper.PagerBlock()
       @PdfHelper.EndArea()
    @PdfHelper.EndBody()
   @PdfHelper.End()

这只是返回上面提到的错误。

日志文件包含以下内容:

 2016-04-19 08:42:41,711 [P16524/D23/T130] ERROR Umbraco.Core.UmbracoApplicationBase - An unhandled exception occurred
System.NullReferenceException: Object reference not set to an instance of an object.
   at ASP.PdfHelper.<Start>b__0(TextWriter __razor_helper_writer) in c:DevelopmentProjectsSupportSupportApp_CodePdfHelper.cshtml:line 5
   at System.Web.WebPages.WebPageBase.Write(HelperResult result)
   at ASP._Page_Views_PDF_cshtml.Execute() in c:DevelopmentProjectsSupportSupportViewsPDF.cshtml:line 12
   at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
   at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
   at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
   at Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer)
   at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at 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 filters, ActionResult actionResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

使用另一个模板修复的问题

最新更新