Copied to clipboard

Flag this post as spam?

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


  • Nathan Woulfe 447 posts 1664 karma points MVP 5x hq c-trib
    Jul 21, 2015 @ 06:05
    Nathan Woulfe
    0

    Extra content at the end of the document error

    Having some issues with rendering using the MVC views

    • If I leave the X-Pdf-Render header in place, I get a blank PDF.
    • If I remove the X-Pdf-Render header and change the content type to text/xml, the xml renders correctly
    • If I remove the X-Pdf-Render header and change the content type to text/xsl, I get "error on line x at column y: Extra content at the end of the document"

    This happens with any of the included example views (PdfMvcExample.cshtml etc).

    I've checked web.config, both keys exist.

    Given that this is happening with any template, I'm thinking it might be an environment issue?

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Jul 21, 2015 @ 11:57
    Darren Ferguson
    0

    Hi Nathan, could you post a blink to your blank PDF?

    Does the PDF contain the metadata that is set by the example view?

    Does the node that you are rendering against contain content for the document type properties that are used the the example templates?

    What happens if you hardcode some text into the example templates?

    Many Thanks.

  • Nathan Woulfe 447 posts 1664 karma points MVP 5x hq c-trib
    Jul 21, 2015 @ 20:29
    Nathan Woulfe
    0

    Hi Darren

    Will check metadata and send a copy of the PDF when I'm back in the office.

    Node definitely has the properties, and the same happens if I try to render a static string - can output xml but get an error with xsl.

  • Nathan Woulfe 447 posts 1664 karma points MVP 5x hq c-trib
    Jul 22, 2015 @ 00:49
    Nathan Woulfe
    0

    Hi Darren

    Generated pdf is here: https://www.dropbox.com/s/ko5pbjk0e6ny4i6/bachelor-of-arts.pdf?dl=0

    It does contain the metadata set by the view, just no content. Have tried @PdfHelper.Block("my text") and it throws the same error...

  • Nathan Woulfe 447 posts 1664 karma points MVP 5x hq c-trib
    Jul 23, 2015 @ 00:06
    Nathan Woulfe
    0

    Having spent a bit more time on this, I might be getting closer to solving it:

    Outputting as xsl renders all the correct content, but with the error. Saving the page and opening in notepad++ shows the expected xml output, with the addition of 81000 (yup, 81k) NUL characters following the element.

    No idea where they'd be coming from or how to tidy 'em up, but that's cause of the error.

  • Nathan Woulfe 447 posts 1664 karma points MVP 5x hq c-trib
    Jul 23, 2015 @ 00:24
    Nathan Woulfe
    0

    Annnnnnnd we have a solution.

    We were using route hijacking to perform some filtering on the model before rendering - this was simply overriding the Index() method, so all requests for the page were passing through the controller regardless of template (at least, that's my understanding of how it works).

    I've changed the controller action to explicitly reference the non-pdf template (ie only hijacking the route for the default template) and all is working fine.

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Jul 23, 2015 @ 09:00
    Darren Ferguson
    0

    Awesome glad to hear you worked it out! Sorry, I was out and about yesterday.

Please Sign in or register to post replies

Write your reply to:

Draft