Change the PDF report name

  • I would like to change the PDF report's name as details.pdf. Here is my request body:

    	"template":{ "shortid":"rJtK3I_zW" },
    	"options": {  "Content-Disposition": "attachment; filename=details.pdf"  }

    However, the PDF report returned from the server still has the name response.pdf.

    Did I miss anything?


  • administrators

    it seems to me that you are doing everything ok, but unfortunately the Content-Disposition header is very tricky, the behaviour depends on the client of the request, sometimes it does not work on IE, or Chrome, etc, you can check/verify that jsreport is applying your options correctly, just check the response headers of the request... i don't know a way to hack the client's request to always use the filename of Content-Disposition.. if you find something please let us know.

  • Thanks, @bjrmatos. Here are the response headers:

    Access-Control-Allow-Origin →*
    Connection →keep-alive
    Content-Disposition →attachment; filename=details.pdf
    Content-Type →application/pdf
    Date →Mon, 10 Jul 2017 15:42:39 GMT
    File-Extension →pdf
    Number-Of-Pages →8
    Transfer-Encoding →chunked
    X-Powered-By →Express
    X-XSS-Protection →0

    Does anything look wrong to you?

  • administrators

    no, everything looks ok. unfortunately it seems that it is the client of the request that is not honoring the Content-Disposition header

  • I see. Thank you, @bjrmatos .

  • I'm having a similar problem where I cannot name reports. In my case each report name is some guid like '023bb970-81fc-4945-a5e9-622578a2a723'. I am new to using jsreportsonline and have never actually gotten a normal report name. In my case requests are being made from node using superagent (I also tried with axios but had the same result):

        const data = {
          "template": {
            "shortid": jsReportOnlineId
          "data": reportData,
          "options": {
            "Content-Disposition": "attachment; filename=myreport.pdf",
        const {username, password} = getJsReportOnlineAuthorizationInfo();
        .set('Content-Type', 'application/json')
        .auth(username, password)
        .end(function (err, response) {

    The generated report looks as desired except for the report name. Here is response header info:

    { date: 'Sat, 15 Jul 2017 14:13:50 GMT',
      'content-type': 'application/pdf',
      'transfer-encoding': 'chunked',
      connection: 'close',
      server: 'nginx/1.13.1',
      'x-powered-by': 'Express',
      'access-control-allow-origin': '*',
      'set-cookie': [Object],
      'content-disposition': 'attachment; filename=myreport.pdf',
      'file-extension': 'pdf',
      'number-of-pages': '2',
      'x-xss-protection': '0' },
    [ 'Date',
      'Sat, 15 Jul 2017 14:13:50 GMT',
      'render-complete=true; Path=/',
      'session=[I removed this]',
      'attachment; filename=myreport.pdf',
      '0' ],

Log in to reply

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