Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Morten Peter Hagh Jensen 25 posts 85 karma points
    Apr 19, 2016 @ 06:55
    Morten Peter Hagh Jensen
    0

    PdfHelper return Object reference not set to an instance on 7.4

    I have installed PDF Creator on a 7.4. installation. If I test using the Razor Example template, I can create a PDF but when using the PdfHelper it returns

    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:  }
    

    I have created a new template:

    <?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()
    

    And this just returns the above mentioned error.

    The log file contains this:

     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:\Development\Projects\Support\Support\App_Code\PdfHelper.cshtml:line 5
       at System.Web.WebPages.WebPageBase.Write(HelperResult result)
       at ASP._Page_Views_PDF_cshtml.Execute() in c:\Development\Projects\Support\Support\Views\PDF.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)
    
  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Apr 20, 2016 @ 07:17
    Darren Ferguson
    0

    Hi,

    You need:

    @using PdfHelper

    Below:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage

    I hope this helps?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies