title: NodeJs says "ReferenceError: window is not defined" with jsPDF
body: <p>I am creating a sample project with NodeJs and jsPDF. When I run, it echos <code>ReferenceError: window is not defined</code>. I also used <a href="https://github.com/vybezi" rel="nofollow noreferrer">John Gordon</a> answer from <a href="https://github.com/MrRio/jsPDF/issues/566#issuecomment-382039316" rel="nofollow noreferrer">here</a>, but again also same problem.</p>
  
  <p><strong>I tried with</strong> </p>
  
  <pre><code>var express = require('express');
  var jsPDF = require('jspdf');
  var app = express();
  
  app.get('/', function(req, res)
  {
      global.window = {document: {createElementNS: () =&gt; {return {}} }};
      global.navigator = {};
      global.btoa = () =&gt; {};
  
      var fs = require('fs');
      var jsPDF = require('jspdf');
      var jsPDFTable = require('jspdf-autotable');
  
      var doc = new jsPDF();
      doc.text("Hello", 10, 10);
      var data = doc.output();
  
      fs.writeFileSync('./tmp/storage/pdf/document.pdf', data);
  
      delete global.window;
      delete global.navigator;
      delete global.btoa;
  });
  
  var port = process.env.PORT || 8080;
  app.listen(port);
  console.log('Server started');
  
  module.exports = app;
  </code></pre>