title: jsreportonline - How to save in pdf file
body: <p>I've finally got the jsreportonline at least generating the file. Here's my code:</p>
  
  <pre><code>request.post({
    url: 'https://xxxx.jsreportonline.net/api/report',
    json: true,
    headers: {
      "Content-Type": "application/json",
      "Authorization" : "Basic "+new Buffer(username:pwd).toString('base64')
    },
    body: {
      "template" : {'shortid" : xxxxx},
      "data" : xxxx,
    }
  }, function(err, res, body) {
    **** HERE IS THE PROBLEM ****
  });
  </code></pre>
  
  <p>I have no clue how to write the pdf output stored within variable 'body' to a file. I've tried:</p>
  
  <pre><code>var pbs = fs.createWriteStream('./report.pdf');
  pbs.write(body);
  pbs.end();
  </code></pre>
  
  <p>I've tried:</p>
  
  <pre><code>var pbs = fs.createWriteStream('./report.pdf', {defaultEncoding: 'binary'});
  </code></pre>
  
  <p>... but the PDF file never is displayed properly. I know the code works because I can set an option on the call:</p>
  
  <pre><code>"options" : {
    "reports" : {"save" : true}
  }
  </code></pre>
  
  <p>... and the report is saved to my jsreportonline account and renders fine.</p>
  
  <p>Thanks for any help.</p>