trim redundant file extension



  • In my script I am setting the whole of the file name based on some report parameters:

    function afterRender(req, res) {
        res.meta.reportName = ('"Campaign Metrics ' + req.data.clca[0]["campaign"] + " - " + req.data.clca[0]["seg"] + '.pdf"')
        res.meta.contentType = 'application/pdf'
    }
    

    but, jsReport is being helpful and adding an extra .pdf

    inline;filename="Campaign Metrics XXXX l Q3 YYYY - All Segments.pdf".pdf
    

    doesn't seem to be causing any real problems, but is there anything I should be doing to stop it doing this (or would it just be a low priority feature request to not append file extension if quoted?)



  • Please try this

    res.meta.reportName = ('"Campaign Metrics ' + req.data.clca[0]["campaign"] + " - " + req.data.clca[0]["seg"] + '.pdf"')
    res.meta.contentType = 'application/pdf'
    res.meta.fileExtension = null
    


  • that actually puts the word .null at the end (replacing with '' just puts .)

    inline;filename="Campaign Metrics XXXX l Q3 YYYY - All Segments.pdf".null


  • Ah ok. You can also set the full content-disposition response header this way

    function afterRender(req, res) {
        res.meta.headers['Content-Disposition'] = 'inline;filename="Campaign Metrics XXXX l Q3 YYYY - All Segments.pdf"'
    }
    


  • perfect, thanks!


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.