Copied to clipboard

Flag this post as spam?

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


  • Gordon Saxby 1461 posts 1883 karma points
    Jan 04, 2012 @ 11:27
    Gordon Saxby
    0

    Naming PDF not working as expected

    I have the following code, but it doesn't handle filenames with spaces :

        <xsl:variable name="fileName">
          <xsl:value-of select="$currentPage/@nodeName" />
          <xsl:text>.pdf</xsl:text>
        </xsl:variable>
        <xsl:value-of select="FergusonMoriyama.Pdf.XsltHelper:AppendResponseHeader('X-Pdf-Force-Download', $fileName)"/>

    If the node name is "Open Day" the PDF is named "open.pdf" ... is this a bug with my code or your helper?

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Jan 04, 2012 @ 22:26
    Darren Ferguson
    0

    Initial glance suggests it is probably to do with whitespace and or / newlines.

    I'd suggest passing in a string value to start with e.g:

    <xsl:value-ofselect="FergusonMoriyama.Pdf.XsltHelper:AppendResponseHeader('X-Pdf-Force-Download', 'OpenDay.pdf')"/>

    And see how that works.

    You may end up having to normalize space and or encode your $filename variable accordingly.

    HTH

  • Gordon Saxby 1461 posts 1883 karma points
    Jan 04, 2012 @ 23:31
    Gordon Saxby
    0

    doing this works -

    umbraco.library:Replace($currentPage/@nodeName, ' ', 'nbsp')

    but it doesn't seem right somehow!? (the nbsp is actually & nbsp ; without the spaces !!)

     

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Jan 05, 2012 @ 08:54
    Darren Ferguson
    0

    Try surrounding the filename with quotes:

    e.g. "My Report.pdf"

    Thanks.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jan 05, 2012 @ 14:50
    Tom Fulton
    0

    I have the same problem but only in Firefox.  I think this is the issue:  http://dotnetslackers.com/Community/blogs/kaushalparik/archive/2009/05/06/file-download-problem-filename-with-spaces-truncated-in-ff-and-replaced-by-underscore-in-ie.aspx

    Maybe it could be fixed in the Helper method, I'm not sure how to enclose in quotes from XSLT.

    -Tom

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Jan 05, 2012 @ 15:14
    Darren Ferguson
    0

    Wouldn't this work:

     

    <xsl:value-ofselect="FergusonMoriyama.Pdf.XsltHelper:AppendResponseHeader('X-Pdf-Force-Download', '&quot;Open Day.pdf&quot;')"/>
  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jan 05, 2012 @ 15:16
    Tom Fulton
    0

    Ah, yes that does the trick for me..thanks.

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Jan 05, 2012 @ 15:17
    Darren Ferguson
    0

    Cool!

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jan 05, 2012 @ 15:18
    Tom Fulton
    0

    Gordon will have to, it's his thread, I came in late and hijacked it :)

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Jan 05, 2012 @ 15:20
    Darren Ferguson
    0

    Sorry - just realised that and edited my response as appropriate.

  • Gordon Saxby 1461 posts 1883 karma points
    Jan 05, 2012 @ 15:59
    Gordon Saxby
    0

    I updated my code to include the quotes around the filename -

        <xsl:variable name="fileName">
          <xsl:text>&quot;</xsl:text>
          <xsl:value-of select="$currentPage/@nodeName" />
          <xsl:text>.pdf</xsl:text>
          <xsl:text>&quot;</xsl:text>
        </xsl:variable>

        <xsl:value-of select="FergusonMoriyama.Pdf.XsltHelper:AppendResponseHeader('X-Pdf-Force-Download', $fileName)"/>

    and it seems to work fine :-)

     

Please Sign in or register to post replies

Write your reply to:

Draft