Copied to clipboard

Flag this post as spam?

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


  • Bob Banks 16 posts 36 karma points
    Mar 26, 2013 @ 16:32
    Bob Banks
    0

    Empty PDF w/ Razor template?

    I'm trying to create a Razor template to render a PDF but all I get is an empty PDF. It appears that some of FO is rendered as I can change the page size but "Hello World" isn't rendered. Compared HTTP response of my template and the PDFRazorHelloWorld template and they match almost exactly. CSHTML source and raw responses below

    Any ideas?

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = null;
    
        Response.ContentType = "text/xml";
        Response.AppendHeader("X-Pdf-Render", "true");
    }<?xml version="1.0" encoding="UTF-8" ?>
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
        <fo:layout-master-set>
        <fo:simple-page-master master-name="A4" page-width="297mm" page-height="210mm" margin-top="1cm" margin-bottom="1cm" margin-left="1cm" margin-right="1cm">
            <fo:region-body margin="3cm"/>
            <fo:region-before extent="2cm"/>
            <fo:region-after extent="2cm"/>
            <fo:region-start extent="2cm"/>
            <fo:region-end extent="2cm"/>
        </fo:simple-page-master>
        </fo:layout-master-set>
    
        <fo:page-sequence master-reference="A4">
        <fo:flow flow-name="xsl-region-body">
            <fo:block>
            <fo:inline font-weight="bold">Hello world!</fo:inline>
            </fo:block>
        </fo:flow>
        </fo:page-sequence>
    </fo:root>

    PDFRazorHelloWorld raw response

    HTTP/1.1 200 OK
    Cache-Control: private
    Content-Type: text/xml; charset=utf-8
    Server: Microsoft-IIS/8.0
    X-AspNet-Version: 4.0.30319
    X-SourceFiles: =?UTF-8?B?RDpcUHJvamVjdHNcQ2hhb3NNYXloZW1VbWJyYWNvXENoYW9zTWF5aGVtVW1icmFjb1xiZWVyLWxpc3RccGluZS1iYXJyZW4tYnJvd25cUGRmUmF6b3JIZWxsb1dvcmxk?=
    X-Powered-By: ASP.NET
    Date: Tue, 26 Mar 2013 15:29:51 GMT
    Content-Length: 889
    
    <?xml version="1.0" encoding="UTF-8" ?>
     <!-- Keep Xml Declaration on the first line -->
    
    
    
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
          <fo:layout-master-set>
            <fo:simple-page-master master-name="A4" page-width="297mm" page-height="210mm" margin-top="1cm" margin-bottom="1cm" margin-left="1cm" margin-right="1cm">
              <fo:region-body margin="3cm"/>
              <fo:region-before extent="2cm"/>
              <fo:region-after extent="2cm"/>
              <fo:region-start extent="2cm"/>
              <fo:region-end extent="2cm"/>
            </fo:simple-page-master>
          </fo:layout-master-set>
    
          <fo:page-sequence master-reference="A4">
            <fo:flow flow-name="xsl-region-body">
              <fo:block>
                <fo:inline font-weight="bold">Hello world!</fo:inline>
              </fo:block>
            </fo:flow>
          </fo:page-sequence>
        </fo:root>

    My template raw response

    HTTP/1.1 200 OK
    Cache-Control: private
    Content-Type: text/xml; charset=utf-8
    Server: Microsoft-IIS/8.0
    X-AspNetMvc-Version: 4.0
    X-AspNet-Version: 4.0.30319
    X-SourceFiles: =?UTF-8?B?RDpcUHJvamVjdHNcQ2hhb3NNYXloZW1VbWJyYWNvXENoYW9zTWF5aGVtVW1icmFjb1xiZWVyLWxpc3RccGluZS1iYXJyZW4tYnJvd25cUGRm?=
    X-Powered-By: ASP.NET
    Date: Tue, 26 Mar 2013 15:29:59 GMT
    Content-Length: 775
    
    <?xml version="1.0" encoding="UTF-8" ?>
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
        <fo:layout-master-set>
        <fo:simple-page-master master-name="A4" page-width="297mm" page-height="210mm" margin-top="1cm" margin-bottom="1cm" margin-left="1cm" margin-right="1cm">
            <fo:region-body margin="3cm"/>
            <fo:region-before extent="2cm"/>
            <fo:region-after extent="2cm"/>
            <fo:region-start extent="2cm"/>
            <fo:region-end extent="2cm"/>
        </fo:simple-page-master>
        </fo:layout-master-set>
    
        <fo:page-sequence master-reference="A4">
        <fo:flow flow-name="xsl-region-body">
            <fo:block>
            <fo:inline font-weight="bold">Hello world!</fo:inline>
            </fo:block>
        </fo:flow>
        </fo:page-sequence>
    </fo:root>

     

     

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Mar 26, 2013 @ 20:57
    Darren Ferguson
    0

    Hi Bob - having a crazy day - I'll have some time to look into this Thursday - but in the meantime have you taken a tool like beyond compare or similar to compare the raw responses and find the difference? (http://www.scootersoftware.com/)

    Feel free to send me your .cshtml file to darren @ moriyama.co.uk and I will try and run it in our environments.

     

    Thanks

     

     

  • Bob Banks 16 posts 36 karma points
    Mar 26, 2013 @ 21:00
    Bob Banks
    0

    Thanks.  Yeah, the only notable differences are in the X-AspNetMvc-Version and X-SourceFiles.  

    The contents of the .cshtml are in the 1st code block.  

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Mar 26, 2013 @ 21:10
    Darren Ferguson
    0

    If you send me the razor file i'll see if it renders for me.

  • Bob Banks 16 posts 36 karma points
    Mar 26, 2013 @ 21:18
    Bob Banks
    0

    Sorry for the misunderstanding.  The content of the razor file is in the 1st code block of the original post.  I've pasted it again below.

     

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = null;
    
        Response.ContentType = "text/xml";
        Response.AppendHeader("X-Pdf-Render", "true");
    }<?xml version="1.0" encoding="UTF-8" ?>
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
        <fo:layout-master-set>
        <fo:simple-page-master master-name="A4" page-width="297mm" page-height="210mm" margin-top="1cm" margin-bottom="1cm" margin-left="1cm" margin-right="1cm">
            <fo:region-body margin="3cm"/>
            <fo:region-before extent="2cm"/>
            <fo:region-after extent="2cm"/>
            <fo:region-start extent="2cm"/>
            <fo:region-end extent="2cm"/>
        </fo:simple-page-master>
        </fo:layout-master-set>
    
        <fo:page-sequence master-reference="A4">
        <fo:flow flow-name="xsl-region-body">
            <fo:block>
            <fo:inline font-weight="bold">Hello world!</fo:inline>
            </fo:block>
        </fo:flow>
        </fo:page-sequence>
    </fo:root>
  • Merijn van Mourik 58 posts 128 karma points
    Apr 13, 2013 @ 11:37
    Merijn van Mourik
    0

    Hi,

    Exactly same situation here. I'm running MVC. I also noticed that during packag installation, the templtes install themselfs as masterpages.... This package needs some improvements to be 6.0.3 (fool) ready :-)

    Merijn

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Apr 15, 2013 @ 10:51
    Darren Ferguson
    0

    You've correctly identified that the package doesn't ship with MVC views yet.

    We'll do this for the next release.

    I'll have a look into why PDFs don't render in MVC view mode and get back to you shortly.

    Thanks.

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Apr 26, 2013 @ 13:07
    Darren Ferguson
    0

    I've managed to reproduce the problem, lookng into it now.

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Apr 26, 2013 @ 15:20
    Darren Ferguson
    0

    I've found the issue - ClientDependency appears to try and compress the output of all responses with content type text/xml.

    It somehow modifies the PDF output to strip out all text which is strange.

    I'll release a patch where you can use the mimetype text/xsl instead. We've tested this here and it works.

    In the meantime you can disable the clientdependency modules in web.config

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Apr 26, 2013 @ 15:48
    Darren Ferguson
    0

    I've just uploaded a new release which will work with the MVC rendering engine.

    Note: you'll need to use the content type text/xsl - as the example in the ~/Views folder does.

Please Sign in or register to post replies

Write your reply to:

Draft