Preview the pdf report

35 views
Skip to first unread message

jmeng...@gmail.com

unread,
Mar 10, 2017, 11:28:21 AM3/10/17
to jsreport

Hi. how can i preview the pdf report before downloading it,while using Node API?.Here is my code

router.get('/reports',function(req,res){
  
   var data ={
     template:{"shortid":"ryK9rleol", "recipe" : "phantom-pdf"},
     data:{'name':'john'},
     options:{ 
       preview: true
      }
   }

  var options ={
    method:'POST',
    json:data

  }

  
  
  request(options).pipe(res);

 
  
 
})

Jan Blaha

unread,
Mar 10, 2017, 11:31:15 AM3/10/17
to jsreport
You can specify the response content disposition header

jmeng...@gmail.com

unread,
Mar 10, 2017, 11:38:22 AM3/10/17
to jsreport
i have added  "options": { "Content-Disposition": "attachment; filename=myreport.pdf" },but its still downloading whenever i call that endpoint.

Jan Blaha

unread,
Mar 10, 2017, 11:40:47 AM3/10/17
to jsreport
Please check the documentation for this header


you should use inline instead of attachment.

jmeng...@gmail.com

unread,
Mar 10, 2017, 12:01:19 PM3/10/17
to jsreport
i dont know what exactly that am doing wrong.i have changed to inline and its still not working.here is my modified code
router.get('/reports',function(req,res){
  
   var data ={
     "template":{"shortid":"ryK9rleol", "recipe" : "phantom-pdf"},
     "data":{'name':'john'},
     "options": {"Content-Disposition":"inline"}
   }

  var options ={
    method:'POST',
    json:data

  }

  
  
  request(options).pipe(res);

 
  
 
})

Jan Blaha

unread,
Mar 10, 2017, 12:09:09 PM3/10/17
to jsreport
The same code works for me. Do you have browser which supports pdf preview? You may need to check your browser settings.
In every case this is not jsreport related...

jmeng...@gmail.com

unread,
Mar 10, 2017, 12:42:00 PM3/10/17
to jsreport
It worked.Seems like i had disabled pdf preview in chrome.Thanks!!
Reply all
Reply to author
Forward
0 new messages